added basic/basic containing badge defaults

This commit is contained in:
kiu 2011-05-21 00:01:53 +02:00
parent 2a58e88fd2
commit 86b2d28ff3
3 changed files with 274 additions and 0 deletions

View File

@ -21,6 +21,7 @@ OBJS = main.o
VPATH += VPATH +=
OBJS += OBJS +=
OBJS += basic/basic.o
OBJS += eeprom/eeprom.o OBJS += eeprom/eeprom.o
LIBS += core/libcore.a lcd/libfont.a LIBS += core/libcore.a lcd/libfont.a

121
basic/basic.c Normal file
View File

@ -0,0 +1,121 @@
#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
gpioSetDir(RB_PWR_GOOD_PORT, RB_PWR_GOOD_PIN, gpioDirection_Output);
gpioSetValue (RB_PWR_GOOD_PORT, RB_PWR_GOOD_PIN, 0);
// prepare buttons
gpioSetDir(RB_BTN0_PORT, RB_BTN0_PIN, gpioDirection_Input);
gpioSetPullup (&RB_BTN0_IO, gpioPullupMode_PullUp);
gpioSetDir(RB_BTN1_PORT, RB_BTN1_PIN, gpioDirection_Input);
gpioSetPullup (&RB_BTN1_IO, gpioPullupMode_PullUp);
gpioSetDir(RB_BTN2_PORT, RB_BTN2_PIN, gpioDirection_Input);
gpioSetPullup (&RB_BTN2_IO, gpioPullupMode_PullUp);
gpioSetDir(RB_BTN3_PORT, RB_BTN3_PIN, gpioDirection_Input);
gpioSetPullup (&RB_BTN3_IO, gpioPullupMode_PullUp);
gpioSetDir(RB_BTN4_PORT, RB_BTN4_PIN, gpioDirection_Input);
gpioSetPullup (&RB_BTN4_IO, gpioPullupMode_PullUp);
// prepare LEDs
gpioSetDir(RB_LED0_PORT, RB_LED0_PIN, gpioDirection_Output);
gpioSetValue (RB_LED0_PORT, RB_LED0_PIN, 1);
gpioSetDir(RB_LED1_PORT, RB_BTN1_PIN, gpioDirection_Output);
gpioSetValue (RB_LED1_PORT, RB_LED1_PIN, 1);
gpioSetDir(RB_LED2_PORT, RB_BTN2_PIN, gpioDirection_Output);
gpioSetValue (RB_LED2_PORT, RB_LED2_PIN, 1);
gpioSetDir(RB_LED3_PORT, RB_LED3_PIN, gpioDirection_Output);
gpioSetValue (RB_LED3_PORT, RB_LED3_PIN, 1);
// prepare IR
gpioSetDir(RB_IROUT_PORT, RB_IROUT_PIN, gpioDirection_Output);
gpioSetValue (RB_IROUT_PORT, RB_IROUT_PIN, 1);
gpioSetDir(RB_IRIN_PORT, RB_IRIN_PIN, gpioDirection_Input);
gpioSetPullup (&RB_IRIN_IO, gpioPullupMode_PullUp);
// prepare lcd
// TODO FIXME more init needed ?
gpioSetDir(RB_LCD_BL_PORT, RB_LCD_BL_PIN, gpioDirection_Output);
gpioSetValue (RB_LCD_BL_PORT, RB_LCD_BL_PIN, 1);
// prepare I2C
#ifdef __I2C_h
i2cInit(I2CMASTER); // TODO FIXME via define ?
#endif
// prepare SPI/SS
// TODO FIXME init miso/mosi/sck somehow ?
gpioSetDir(RB_SPI_SS0_PORT, RB_SPI_SS0_PIN, gpioDirection_Output);
gpioSetValue (RB_SPI_SS0_PORT, RB_SPI_SS0_PIN, 1);
gpioSetDir(RB_SPI_SS1_PORT, RB_SPI_SS1_PIN, gpioDirection_Output);
gpioSetValue (RB_SPI_SS1_PORT, RB_SPI_SS1_PIN, 1);
gpioSetDir(RB_SPI_SS2_PORT, RB_SPI_SS2_PIN, gpioDirection_Output);
gpioSetValue (RB_SPI_SS2_PORT, RB_SPI_SS2_PIN, 1);
gpioSetDir(RB_SPI_SS3_PORT, RB_SPI_SS3_PIN, gpioDirection_Output);
gpioSetValue (RB_SPI_SS3_PORT, RB_SPI_SS3_PIN, 1);
gpioSetDir(RB_SPI_SS4_PORT, RB_SPI_SS4_PIN, gpioDirection_Output);
gpioSetValue (RB_SPI_SS4_PORT, RB_SPI_SS4_PIN, 1);
gpioSetDir(RB_SPI_SS5_PORT, RB_SPI_SS5_PIN, gpioDirection_Output);
gpioSetValue (RB_SPI_SS5_PORT, RB_SPI_SS5_PIN, 1);
// prepare hackerbus
gpioSetDir(RB_HB0_PORT, RB_HB0_PIN, gpioDirection_Output);
gpioSetValue (RB_HB0_PORT, RB_HB0_PIN, 1);
gpioSetDir(RB_HB1_PORT, RB_HB1_PIN, gpioDirection_Output);
gpioSetValue (RB_HB1_PORT, RB_HB1_PIN, 1);
gpioSetDir(RB_HB2_PORT, RB_HB2_PIN, gpioDirection_Output);
gpioSetValue (RB_HB2_PORT, RB_HB2_PIN, 1);
gpioSetDir(RB_HB3_PORT, RB_HB3_PIN, gpioDirection_Output);
gpioSetValue (RB_HB3_PORT, RB_HB3_PIN, 1);
gpioSetDir(RB_HB4_PORT, RB_HB4_PIN, gpioDirection_Output);
gpioSetValue (RB_HB4_PORT, RB_HB4_PIN, 1);
gpioSetDir(RB_HB5_PORT, RB_HB5_PIN, gpioDirection_Output);
gpioSetValue (RB_HB5_PORT, RB_HB5_PIN, 1);
// prepare BUSINT interrupt
gpioSetDir(RB_BUSINT_PORT, RB_BUSINT_PIN, gpioDirection_Input);
gpioSetPullup (&RB_BUSINT_IO, gpioPullupMode_PullUp);
gpioSetInterrupt(RB_BUSINT_PORT, RB_BUSINT_PIN, gpioInterruptSense_Edge, gpioInterruptEdge_Single, gpioInterruptEvent_ActiveLow);
gpioIntEnable(RB_BUSINT_PORT, RB_BUSINT_PIN);
//add this to catch interrupt:
/*
void PIOINT3_IRQHandler(void) {
if (gpioIntStatus(RB_BUSINT_PORT, RB_BUSINT_PIN)) {
// do something
gpioIntClear(RB_BUSINT_PORT, RB_BUSINT_PIN);
}
}
*/
}

152
basic/basic.h Normal file
View File

@ -0,0 +1,152 @@
#ifndef __BASIC_H_
#define __BASIC_H_
#include "core/gpio/gpio.h"
#include "core/adc/adc.h"
// LED
#define RB_LED0_PORT 0
#define RB_LED0_PIN 11
#define RB_LED1_PORT 1
#define RB_LED1_PIN 7
#define RB_LED2_PORT 1
#define RB_LED2_PIN 6
#define RB_LED3_PORT 1
#define RB_LED3_PIN 11
// Infrared
#define RB_IROUT_PORT 1
#define RB_IROUT_PIN 5
#define RB_IRIN_PORT 1
#define RB_IRIN_PIN 8
#define RB_IRIN_IO IOCON_PIO1_8
// Buttons
#define RB_BTN0_PORT 0
#define RB_BTN0_PIN 1
#define RB_BTN0_IO IOCON_PIO0_1
#define RB_BTN1_PORT 2
#define RB_BTN1_PIN 9
#define RB_BTN1_IO IOCON_PIO2_9
#define RB_BTN2_PORT 2
#define RB_BTN2_PIN 6
#define RB_BTN2_IO IOCON_PIO2_6
#define RB_BTN3_PORT 3
#define RB_BTN3_PIN 3
#define RB_BTN3_IO IOCON_PIO3_3
#define RB_BTN4_PORT 1
#define RB_BTN4_PIN 4
#define RB_BTN4_IO IOCON_PIO1_4
// LCD
#define RB_LCD_BL_PORT 1
#define RB_LCD_BL_PIN 10
#define RB_LCD_A0_PORT 2
#define RB_LCD_A0_PIN 0
#define RB_LCD_CS_PORT 2
#define RB_LCD_CS_PIN 1
#define RB_LCD_RST_PORT 2
#define RB_LCD_RST_PIN 2
// I2C
#define RB_I2C_SCL_PORT 0
#define RB_I2C_SCL_PIN 4
#define RB_I2C_SCA_PORT 0
#define RB_I2C_SCA_PIN 5
// SPI
#define RB_SPI_MISO_PORT 0
#define RB_SPI_MISO_PIN 8
#define RB_SPI_MOSI_PORT 0
#define RB_SPI_MOSI_PIN 9
#define RB_SPI_SCK_PORT 0
#define RB_SPI_SCK_PIN 10
#define RB_SPI_SS0_PORT 2
#define RB_SPI_SS0_PIN 5
#define RB_SPI_SS1_PORT 2
#define RB_SPI_SS1_PIN 4
#define RB_SPI_SS2_PORT 2
#define RB_SPI_SS2_PIN 8
#define RB_SPI_SS3_PORT 3
#define RB_SPI_SS3_PIN 2
#define RB_SPI_SS4_PORT 3
#define RB_SPI_SS4_PIN 1
#define RB_SPI_SS5_PORT 2
#define RB_SPI_SS5_PIN 11
// Power
#define RB_PWR_VOLT_PORT 1
#define RB_PWR_VOLT_PIN 0
#define RB_PWR_GOOD_PORT 1
#define RB_PWR_GOOD_PIN 9
#define RB_PWR_CHRG_PORT 2
#define RB_PWR_CHRG_PIN 3
// Hackerbus
#define RB_HB0_PORT 1
#define RB_HB0_PIN 3
#define RB_HB0_IO IOCON_PIO1_3
#define RB_HB1_PORT 1
#define RB_HB1_PIN 2
#define RB_HB1_IO IOCON_PIO1_2
#define RB_HB2_PORT 1
#define RB_HB2_PIN 1
#define RB_HB2_IO IOCON_PIO1_1
#define RB_HB3_PORT 0
#define RB_HB3_PIN 2
#define RB_HB3_IO IOCON_PIO0_2
#define RB_HB4_PORT 2
#define RB_HB4_PIN 7
#define RB_HB4_IO IOCON_PIO2_7
#define RB_HB5_PORT 0
#define RB_HB5_PIN 6
#define RB_HB5_IO IOCON_PIO0_6
// Misc
#define RB_BUSINT_PORT 3
#define RB_BUSINT_PIN 0
#define RB_BUSINT_IO IOCON_PIO3_0
#define RB_USB_VBUS_PORT 0
#define RB_USB_VBUS_PIN 3
#define RB_EEPROM_ADDR 0xA0
void rbInit(void);
#endif