/****************************************************************************/
/* Copyright 2015 MBARI                                                     */
/****************************************************************************/
/* Summary  : Peripheral Module Disable for Oasis5 on PIC32MX470            */
/* Filename : periph.c                                                      */
/* Author   : Robert Herlien (rah)                                          */
/* Project  : OASIS Mooring Replacement (OASIS5)                            */
/* Revision: 1.0                                                            */
/* Created  : 07/16/2015                                                    */
/*                                                                          */
/* MBARI provides this documentation and code "as is", with no warranty,    */
/* express or implied, of its quality or consistency. It is provided without*/
/* support and without obligation on the part of the Monterey Bay Aquarium  */
/* Research Institute to assist in its use, correction, modification, or    */
/* enhancement. This information should not be published or distributed to  */
/* third parties without specific written permission from MBARI.            */
/*                                                                          */
/****************************************************************************/
/* Modification History:                                                    */
/* 16jul2015 rah - created                                                  */
/****************************************************************************/

#include <xc.h>
#include "periph.h"

void periphInit()
{
    /********************** Disable Unused Peripherals **********************/
    PMD1CLR = _PMD1_AD1MD_MASK;     /* A/D module on                        */
    PMD1SET = _PMD1_CTMUMD_MASK;    /* Charge Time Measurement Unit off     */
    PMD1SET = _PMD1_CVRMD_MASK;     /* Comparator Voltage Reference off     */
    PMD2SET = _PMD2_CMP1MD_MASK;    /* Comparators off                      */
    PMD2SET = _PMD2_CMP2MD_MASK;
    PMD3SET = _PMD3_IC1MD_MASK;     /* Input Captures off                   */
    PMD3SET = _PMD3_IC2MD_MASK;
    PMD3SET = _PMD3_IC3MD_MASK;
    PMD3SET = _PMD3_IC4MD_MASK;
    PMD3SET = _PMD3_IC5MD_MASK;
    PMD3SET = _PMD3_OC1MD_MASK;     /* Output Compares off                  */
    PMD3SET = _PMD3_OC2MD_MASK;
    PMD3SET = _PMD3_OC3MD_MASK;
    PMD3SET = _PMD3_OC4MD_MASK;
    PMD3SET = _PMD3_OC5MD_MASK;
    PMD4CLR = _PMD4_T1MD_MASK;      /* Timer 1-3 on                         */
    PMD4CLR = _PMD4_T2MD_MASK;
    PMD4CLR = _PMD4_T3MD_MASK;
    PMD4SET = _PMD4_T4MD_MASK;      /* Timers 4-5 off                       */
    PMD4SET = _PMD4_T5MD_MASK;
    PMD5CLR = _PMD5_U1MD_MASK;      /* UARTS on                             */
    PMD5CLR = _PMD5_U2MD_MASK;
    PMD5CLR = _PMD5_U3MD_MASK;
    PMD5CLR = _PMD5_U4MD_MASK;
    PMD5CLR = _PMD5_U5MD_MASK;
    PMD5CLR = _PMD5_SPI1MD_MASK;    /* SPI1 on                              */
    PMD5CLR = _PMD5_SPI2MD_MASK;    /* SPI2 on                              */
    PMD5CLR = _PMD5_I2C1MD_MASK;    /* I2C bus 1 on                         */
    PMD5SET = _PMD5_I2C2MD_MASK;    /* I2C bus 2 off                        */
    PMD5SET = _PMD5_USBMD_MASK;     /* USB off                              */
    PMD6SET = _PMD6_RTCCMD_MASK;    /* RTC off                              */
    PMD6CLR = _PMD6_REFOMD_MASK;    /* Reference clock output on            */
    PMD6SET = _PMD6_PMPMD_MASK;     /* Parallel Master Port off             */

}
