Page MenuHomec4science

pindefs.c
No OneTemporary

File Metadata

Created
Sat, Nov 9, 12:21

pindefs.c

#include "p33FJ128GP802.h"
#include "pindefs.h"
/** \brief initialize all the pins for I/O
* initialize all the pins for I/O
*/
void pin_init()
{
// pin default configuration
ADPCFG = 0xFFFF; // Set all Analog ports as Digital I/O
// battery power monitoring
TRISAbits.TRISA0 = 1; // BATT_VOLTAGE is input
TRISAbits.TRISA1 = 1; // BATT_CURRENT is input
// enable signals for power supplies
TRISAbits.TRISA3 = 0; // SERVO_VOLTAGE_EN is output
TRISAbits.TRISA4 = 0; // DIGITAL_VOLTAGE_EN is output
TRISBbits.TRISB3 = 0; // MOTOR_VOLTAGE_EN is output
TRISBbits.TRISB2 = 0; // POWER_EN is output
// switch button inputs
TRISBbits.TRISB12 = 1; // SW1 is input
TRISBbits.TRISB0 = 1; // SW2 is input
TRISBbits.TRISB1 = 1; // SW3 is input
// led driver interface
TRISBbits.TRISB4 = 0; // LED_CLK is output
TRISBbits.TRISB13 = 0; // LED_LE is output
TRISBbits.TRISB14 = 0; // LED_OE is output
TRISBbits.TRISB15 = 0; // LED_SDO is output
// speaker output
TRISBbits.TRISB11 = 0; // SPEAKER is output
_RP11R = 0b10010; // Map OC1 to RP11
//-------------- SPI 1 -------------------------------------------
_RP15R = 0b00111; // Map SPI SDO to RP15
_RP4R = 0b01000; // Map SPI SCK out to RP4
}

Event Timeline