2011-05-20 22:01:53 +00:00
|
|
|
#include "basic.h"
|
|
|
|
#include "core/gpio/gpio.h"
|
|
|
|
|
|
|
|
void rbInit() {
|
|
|
|
|
|
|
|
// TODO FIXME special port disable ? LEDs BTNs ?
|
|
|
|
|
|
|
|
// prepare power
|
|
|
|
// TODO FIXME more power init needed ? chrg + volt input ?
|
|
|
|
// enable external vcc
|
2011-05-20 22:31:58 +00:00
|
|
|
gpioSetDir(RB_PWR_GOOD, gpioDirection_Output);
|
|
|
|
gpioSetValue (RB_PWR_GOOD, 0);
|
2011-05-20 22:01:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
// prepare buttons
|
2011-05-20 22:31:58 +00:00
|
|
|
gpioSetDir(RB_BTN0, gpioDirection_Input);
|
2011-05-20 22:01:53 +00:00
|
|
|
gpioSetPullup (&RB_BTN0_IO, gpioPullupMode_PullUp);
|
|
|
|
|
2011-05-20 22:31:58 +00:00
|
|
|
gpioSetDir(RB_BTN1, gpioDirection_Input);
|
2011-05-20 22:01:53 +00:00
|
|
|
gpioSetPullup (&RB_BTN1_IO, gpioPullupMode_PullUp);
|
|
|
|
|
2011-05-20 22:31:58 +00:00
|
|
|
gpioSetDir(RB_BTN2, gpioDirection_Input);
|
2011-05-20 22:01:53 +00:00
|
|
|
gpioSetPullup (&RB_BTN2_IO, gpioPullupMode_PullUp);
|
|
|
|
|
2011-05-20 22:31:58 +00:00
|
|
|
gpioSetDir(RB_BTN3, gpioDirection_Input);
|
2011-05-20 22:01:53 +00:00
|
|
|
gpioSetPullup (&RB_BTN3_IO, gpioPullupMode_PullUp);
|
|
|
|
|
2011-05-20 22:31:58 +00:00
|
|
|
gpioSetDir(RB_BTN4, gpioDirection_Input);
|
2011-05-20 22:01:53 +00:00
|
|
|
gpioSetPullup (&RB_BTN4_IO, gpioPullupMode_PullUp);
|
|
|
|
|
|
|
|
|
|
|
|
// prepare LEDs
|
2011-05-20 22:31:58 +00:00
|
|
|
gpioSetDir(RB_LED0, gpioDirection_Output);
|
|
|
|
gpioSetValue (RB_LED0, 1);
|
2011-05-20 22:01:53 +00:00
|
|
|
|
2011-05-20 22:31:58 +00:00
|
|
|
gpioSetDir(RB_LED1, gpioDirection_Output);
|
|
|
|
gpioSetValue (RB_LED1, 1);
|
2011-05-20 22:01:53 +00:00
|
|
|
|
2011-05-20 22:31:58 +00:00
|
|
|
gpioSetDir(RB_LED2, gpioDirection_Output);
|
|
|
|
gpioSetValue (RB_LED2, 1);
|
2011-05-20 22:01:53 +00:00
|
|
|
|
2011-05-20 22:31:58 +00:00
|
|
|
gpioSetDir(RB_LED3, gpioDirection_Output);
|
|
|
|
gpioSetValue (RB_LED3, 1);
|
2011-05-20 22:01:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
// prepare IR
|
2011-05-20 22:31:58 +00:00
|
|
|
gpioSetDir(RB_IROUT, gpioDirection_Output);
|
|
|
|
gpioSetValue (RB_IROUT, 1);
|
2011-05-20 22:01:53 +00:00
|
|
|
|
2011-05-20 22:31:58 +00:00
|
|
|
gpioSetDir(RB_IRIN, gpioDirection_Input);
|
2011-05-20 22:01:53 +00:00
|
|
|
gpioSetPullup (&RB_IRIN_IO, gpioPullupMode_PullUp);
|
|
|
|
|
|
|
|
|
|
|
|
// prepare lcd
|
|
|
|
// TODO FIXME more init needed ?
|
2011-05-20 22:31:58 +00:00
|
|
|
gpioSetDir(RB_LCD_BL, gpioDirection_Output);
|
|
|
|
gpioSetValue (RB_LCD_BL, 1);
|
2011-05-20 22:01:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
// prepare I2C
|
|
|
|
#ifdef __I2C_h
|
|
|
|
i2cInit(I2CMASTER); // TODO FIXME via define ?
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
// prepare SPI/SS
|
|
|
|
// TODO FIXME init miso/mosi/sck somehow ?
|
2011-05-20 22:31:58 +00:00
|
|
|
gpioSetDir(RB_SPI_SS0, gpioDirection_Output);
|
|
|
|
gpioSetValue (RB_SPI_SS0, 1);
|
2011-05-20 22:01:53 +00:00
|
|
|
|
2011-05-20 22:31:58 +00:00
|
|
|
gpioSetDir(RB_SPI_SS1, gpioDirection_Output);
|
|
|
|
gpioSetValue (RB_SPI_SS1, 1);
|
2011-05-20 22:01:53 +00:00
|
|
|
|
2011-05-20 22:31:58 +00:00
|
|
|
gpioSetDir(RB_SPI_SS2, gpioDirection_Output);
|
|
|
|
gpioSetValue (RB_SPI_SS2, 1);
|
2011-05-20 22:01:53 +00:00
|
|
|
|
2011-05-20 22:31:58 +00:00
|
|
|
gpioSetDir(RB_SPI_SS3, gpioDirection_Output);
|
|
|
|
gpioSetValue (RB_SPI_SS3, 1);
|
2011-05-20 22:01:53 +00:00
|
|
|
|
2011-05-20 22:31:58 +00:00
|
|
|
gpioSetDir(RB_SPI_SS4, gpioDirection_Output);
|
|
|
|
gpioSetValue (RB_SPI_SS4, 1);
|
2011-05-20 22:01:53 +00:00
|
|
|
|
2011-05-20 22:31:58 +00:00
|
|
|
gpioSetDir(RB_SPI_SS5, gpioDirection_Output);
|
|
|
|
gpioSetValue (RB_SPI_SS5, 1);
|
2011-05-20 22:01:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
// prepare hackerbus
|
2011-05-20 22:31:58 +00:00
|
|
|
gpioSetDir(RB_HB0, gpioDirection_Output);
|
|
|
|
gpioSetValue (RB_HB0, 1);
|
2011-05-20 22:01:53 +00:00
|
|
|
|
2011-05-20 22:31:58 +00:00
|
|
|
gpioSetDir(RB_HB1, gpioDirection_Output);
|
|
|
|
gpioSetValue (RB_HB1, 1);
|
2011-05-20 22:01:53 +00:00
|
|
|
|
2011-05-20 22:31:58 +00:00
|
|
|
gpioSetDir(RB_HB2, gpioDirection_Output);
|
|
|
|
gpioSetValue (RB_HB2, 1);
|
2011-05-20 22:01:53 +00:00
|
|
|
|
2011-05-20 22:31:58 +00:00
|
|
|
gpioSetDir(RB_HB3, gpioDirection_Output);
|
|
|
|
gpioSetValue (RB_HB3, 1);
|
2011-05-20 22:01:53 +00:00
|
|
|
|
2011-05-20 22:31:58 +00:00
|
|
|
gpioSetDir(RB_HB4, gpioDirection_Output);
|
|
|
|
gpioSetValue (RB_HB4, 1);
|
2011-05-20 22:01:53 +00:00
|
|
|
|
2011-05-20 22:31:58 +00:00
|
|
|
gpioSetDir(RB_HB5, gpioDirection_Output);
|
|
|
|
gpioSetValue (RB_HB5, 1);
|
2011-05-20 22:01:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
// prepare BUSINT interrupt
|
2011-05-20 22:31:58 +00:00
|
|
|
gpioSetDir(RB_BUSINT, gpioDirection_Input);
|
2011-05-20 22:01:53 +00:00
|
|
|
gpioSetPullup (&RB_BUSINT_IO, gpioPullupMode_PullUp);
|
2011-05-20 22:31:58 +00:00
|
|
|
gpioSetInterrupt(RB_BUSINT, gpioInterruptSense_Edge, gpioInterruptEdge_Single, gpioInterruptEvent_ActiveLow);
|
|
|
|
gpioIntEnable(RB_BUSINT);
|
2011-05-21 08:25:05 +00:00
|
|
|
// add this to catch interrupt:
|
2011-05-20 22:01:53 +00:00
|
|
|
/*
|
|
|
|
void PIOINT3_IRQHandler(void) {
|
2011-05-20 22:31:58 +00:00
|
|
|
if (gpioIntStatus(RB_BUSINT)) {
|
2011-05-20 22:01:53 +00:00
|
|
|
// do something
|
2011-05-20 22:31:58 +00:00
|
|
|
gpioIntClear(RB_BUSINT);
|
2011-05-20 22:01:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
}
|