modified code for new pcb

This commit is contained in:
schneider 2011-06-12 22:54:41 +02:00
parent c8e456f16e
commit 8903c52d22
12 changed files with 95 additions and 52 deletions

View File

@ -2,7 +2,6 @@
#include "core/gpio/gpio.h" #include "core/gpio/gpio.h"
void rbInit() { void rbInit() {
// TODO FIXME special port disable ? LEDs BTNs ? // TODO FIXME special port disable ? LEDs BTNs ?
// prepare power // prepare power
@ -30,6 +29,9 @@ void rbInit() {
// prepare LEDs // prepare LEDs
IOCON_JTAG_TDI_PIO0_11 &= ~IOCON_JTAG_TDI_PIO0_11_FUNC_MASK;
IOCON_JTAG_TDI_PIO0_11 |= IOCON_JTAG_TDI_PIO0_11_FUNC_GPIO;
gpioSetDir(RB_LED0, gpioDirection_Output); gpioSetDir(RB_LED0, gpioDirection_Output);
gpioSetValue (RB_LED0, 1); gpioSetValue (RB_LED0, 1);
@ -44,18 +46,23 @@ void rbInit() {
// prepare IR // prepare IR
gpioSetDir(RB_IROUT, gpioDirection_Output); //gpioSetDir(RB_IROUT, gpioDirection_Output);
gpioSetValue (RB_IROUT, 1); //gpioSetValue (RB_IROUT, 1);
gpioSetDir(RB_IRIN, gpioDirection_Input); //gpioSetDir(RB_IRIN, gpioDirection_Input);
gpioSetPullup (&RB_IRIN_IO, gpioPullupMode_PullUp); //gpioSetPullup (&RB_IRIN_IO, gpioPullupMode_PullUp);
// prepare lcd // prepare lcd
// TODO FIXME more init needed ? // TODO FIXME more init needed ?
gpioSetDir(RB_LCD_BL, gpioDirection_Output); gpioSetDir(RB_LCD_BL, gpioDirection_Output);
gpioSetValue (RB_LCD_BL, 1); gpioSetValue (RB_LCD_BL, 0);
// Set P0.0 to GPIO
RB_PWR_LCDBL_IO&= ~RB_PWR_LCDBL_IO_FUNC_MASK;
RB_PWR_LCDBL_IO|= RB_PWR_LCDBL_IO_FUNC_GPIO;
gpioSetDir(RB_PWR_LCDBL, gpioDirection_Input);
gpioSetPullup(&RB_PWR_LCDBL_IO, gpioPullupMode_Inactive);
// prepare I2C // prepare I2C
#ifdef __I2C_h #ifdef __I2C_h

View File

@ -15,10 +15,10 @@
// Infrared // Infrared
#define RB_IROUT 1,5 //#define RB_IROUT 1,5
#define RB_IRIN 1,8 //#define RB_IRIN 1,8
#define RB_IRIN_IO IOCON_PIO1_8 //#define RB_IRIN_IO IOCON_PIO1_8
// Buttons // Buttons
@ -34,14 +34,14 @@
#define RB_BTN3 3,3 #define RB_BTN3 3,3
#define RB_BTN3_IO IOCON_PIO3_3 #define RB_BTN3_IO IOCON_PIO3_3
#define RB_BTN4 1,4 #define RB_BTN4 2,7
#define RB_BTN4_IO IOCON_PIO1_4 #define RB_BTN4_IO IOCON_PIO2_7
// LCD // LCD
#define RB_LCD_BL 1,10 #define RB_LCD_BL 1,9
#define RB_LCD_A0 2,0 //#define RB_LCD_A0 2,0
#define RB_LCD_CS 2,1 #define RB_LCD_CS 2,1
@ -59,7 +59,7 @@
#define RB_SPI_MOSI 0,9 #define RB_SPI_MOSI 0,9
#define RB_SPI_SCK 0,10 #define RB_SPI_SCK 2,11
#define RB_SPI_SS0 2,5 #define RB_SPI_SS0 2,5
@ -71,23 +71,27 @@
#define RB_SPI_SS4 3,1 #define RB_SPI_SS4 3,1
#define RB_SPI_SS5 2,11 #define RB_SPI_SS5 2,10
// Power // Power
#define RB_PWR_VOLT 1,0 #define RB_PWR_VOLT 1,0
#define RB_PWR_GOOD 1,9 #define RB_PWR_GOOD 1,8
#define RB_PWR_CHRG 2,3 #define RB_PWR_CHRG 2,3
#define RB_PWR_LCDBL 0,0
#define RB_PWR_LCDBL_IO IOCON_nRESET_PIO0_0
#define RB_PWR_LCDBL_IO_FUNC_MASK IOCON_nRESET_PIO0_0_FUNC_MASK
#define RB_PWR_LCDBL_IO_FUNC_GPIO IOCON_nRESET_PIO0_0_FUNC_GPIO
// Hackerbus // Hackerbus
#define RB_HB0 1,3 #define RB_HB0 1,3
#define RB_HB0_IO IOCON_PIO1_3 #define RB_HB0_IO IOCON_PIO1_3
#define RB_HB1 1,2 #define RB_HB1 0,10
#define RB_HB1_IO IOCON_PIO1_2 #define RB_HB1_IO IOCON_PIO0_10
#define RB_HB2 1,1 #define RB_HB2 1,1
#define RB_HB2_IO IOCON_PIO1_1 #define RB_HB2_IO IOCON_PIO1_1
@ -95,11 +99,11 @@
#define RB_HB3 0,2 #define RB_HB3 0,2
#define RB_HB3_IO IOCON_PIO0_2 #define RB_HB3_IO IOCON_PIO0_2
#define RB_HB4 2,7 #define RB_HB4 1,4
#define RB_HB4_IO IOCON_PIO2_7 #define RB_HB4_IO IOCON_PIO1_4
#define RB_HB5 0,6 #define RB_HB5 1,2
#define RB_HB5_IO IOCON_PIO0_6 #define RB_HB5_IO IOCON_PIO1_2
// Misc // Misc

View File

@ -3,6 +3,8 @@
*/ */
#include "lpc134x.h" #include "lpc134x.h"
#include "sysdefs.h" #include "sysdefs.h"
#include "core/gpio/gpio.h"
#include "basic/basic.h"
uint32_t brightness = 100; uint32_t brightness = 100;
@ -10,31 +12,42 @@ void backlightInit(void) {
/* Enable the clock for CT16B1 */ /* Enable the clock for CT16B1 */
SCB_SYSAHBCLKCTRL |= (SCB_SYSAHBCLKCTRL_CT16B1); SCB_SYSAHBCLKCTRL |= (SCB_SYSAHBCLKCTRL_CT16B1);
/* Configure PIO1.10 as Timer1_16 MAT1 Output */ /* Configure PIO1.9 as Timer1_16 MAT0 Output */
IOCON_PIO1_10 &= ~IOCON_PIO1_10_FUNC_MASK; IOCON_PIO1_9 &= ~IOCON_PIO1_9_FUNC_MASK;
IOCON_PIO1_10 |= IOCON_PIO1_10_FUNC_CT16B1_MAT1; IOCON_PIO1_9 |= IOCON_PIO1_9_FUNC_CT16B1_MAT0;
/* Set default duty cycle (MR1) */ /* Set default duty cycle (MR1) */
TMR_TMR16B1MR1 = (0xFFFF * (100 - brightness)) / 100; TMR_TMR16B1MR0 = (0xFFFF * (100 - brightness)) / 100;
/* External Match Register Settings for PWM */ /* External Match Register Settings for PWM */
TMR_TMR16B1EMR = TMR_TMR16B1EMR_EMC1_TOGGLE | TMR_TMR16B1EMR_EM1; TMR_TMR16B1EMR = TMR_TMR16B1EMR_EMC0_TOGGLE | TMR_TMR16B1EMR_EM0;
/* enable Timer1 */ /* enable Timer1 */
TMR_TMR16B1TCR = TMR_TMR16B1TCR_COUNTERENABLE_ENABLED; TMR_TMR16B1TCR = TMR_TMR16B1TCR_COUNTERENABLE_ENABLED;
/* Enable PWM1 */ /* Enable PWM0 */
TMR_TMR16B1PWMC = TMR_TMR16B1PWMC_PWM1_ENABLED; TMR_TMR16B1PWMC = TMR_TMR16B1PWMC_PWM0_ENABLED;
// Enable Step-UP
gpioSetDir(RB_PWR_LCDBL, gpioDirection_Output);
gpioSetValue(RB_PWR_LCDBL, 0);
} }
int backlightSetBrightness(uint32_t percentage) { int backlightSetBrightness(uint32_t percentage) {
if ((percentage < 1) || (percentage > 100)) { if ((percentage < 0) || (percentage > 100)) {
/* brightness must be a value between 1 and 100 */ /* brightness must be a value between 1 and 100 */
return -1; return -1;
} }
if( percentage == 0 ){
gpioSetDir(RB_PWR_LCDBL, gpioDirection_Input);
}else{
gpioSetDir(RB_PWR_LCDBL, gpioDirection_Output);
gpioSetValue(RB_PWR_LCDBL, 0);
}
/* Set Duty Cycle (MR1) */ /* Set Duty Cycle (MR1) */
TMR_TMR16B1MR1 = (0xFFFF * (100 - (brightness = percentage))) / 100; TMR_TMR16B1MR0 = (0xFFFF * (100 - (brightness = percentage))) / 100;
return 0; return 0;
} }

View File

@ -41,8 +41,10 @@ int inverted = 0;
*/ */
#define CS 2,1 #define CS 2,1
#define SCK 0,10 #define SCK 2,11
//#define SCK 2,8
#define SDA 0,9 #define SDA 0,9
//#define SDA 2,8
#define RST 2,2 #define RST 2,2
void lcdWrite(uint8_t cd, uint8_t data) void lcdWrite(uint8_t cd, uint8_t data)
@ -116,8 +118,7 @@ void lcdRead(uint8_t data)
void lcdInit(void) void lcdInit(void)
{ {
IOCON_SWCLK_PIO0_10 = 0x51; //IOCON_SWCLK_PIO0_10 = 0x51;
gpioSetValue(RST, 1); gpioSetValue(RST, 1);
gpioSetValue(CS, 1); gpioSetValue(CS, 1);

1
main.c
View File

@ -20,6 +20,7 @@ int main(void) {
//enable clocks to adc and watchdog //enable clocks to adc and watchdog
pmuInit(); pmuInit();
// initialise basic badge functions // initialise basic badge functions
rbInit(); rbInit();

View File

@ -69,13 +69,13 @@ void delayms(int);
uint8_t getInput(void) { uint8_t getInput(void) {
uint8_t result = BTN_NONE; uint8_t result = BTN_NONE;
if (gpioGetValue(RB_BTN1)==0) { if (gpioGetValue(RB_BTN3)==0) {
while(gpioGetValue(RB_BTN1)==0); while(gpioGetValue(RB_BTN3)==0);
result += BTN_UP; result += BTN_UP;
} }
if (gpioGetValue(RB_BTN0)==0) { if (gpioGetValue(RB_BTN2)==0) {
while(gpioGetValue(RB_BTN0)==0); while(gpioGetValue(RB_BTN2)==0);
result += BTN_DOWN; result += BTN_DOWN;
} }
@ -84,13 +84,13 @@ uint8_t getInput(void) {
result += BTN_ENTER; result += BTN_ENTER;
} }
if (gpioGetValue(RB_BTN2)==0) { if (gpioGetValue(RB_BTN0)==0) {
while(gpioGetValue(RB_BTN2)==0); while(gpioGetValue(RB_BTN0)==0);
result += BTN_LEFT; result += BTN_LEFT;
} }
if (gpioGetValue(RB_BTN3)==0) { if (gpioGetValue(RB_BTN1)==0) {
while(gpioGetValue(RB_BTN3)==0); while(gpioGetValue(RB_BTN1)==0);
result += BTN_RIGHT; result += BTN_RIGHT;
} }

View File

@ -16,6 +16,8 @@ void module_sec(void) {
gpioSetDir(RB_LED3, gpioDirection_Input); gpioSetDir(RB_LED3, gpioDirection_Input);
IOCON_PIO1_11 = 0x41; IOCON_PIO1_11 = 0x41;
backlightInit();
uint32_t j=0; uint32_t j=0;
//disable the JTAG on PIO3_3 //disable the JTAG on PIO3_3

View File

@ -13,6 +13,7 @@ APP_SRC= \
src/nRF_API.c \ src/nRF_API.c \
src/pin.c \ src/pin.c \
src/pmu.c \ src/pmu.c \
src/display.c
# src/storage.c # src/storage.c
APP_SRC+=$(IMAGES_C) APP_SRC+=$(IMAGES_C)

View File

@ -42,6 +42,6 @@
#define TASK_NRF_STACK_SIZE 256 #define TASK_NRF_STACK_SIZE 256
#define TASK_NRF_PRIORITY (tskIDLE_PRIORITY + 2) #define TASK_NRF_PRIORITY (tskIDLE_PRIORITY + 2)
#define UPDATE_INTERVAL_MS 50 #define UPDATE_INTERVAL_MS 250
#endif/*__CONFIG_H__*/ #endif/*__CONFIG_H__*/

View File

@ -33,13 +33,15 @@
#include "nRF_API.h" #include "nRF_API.h"
#include "nRF_CMD.h" #include "nRF_CMD.h"
#include "openbeacon-proto.h" #include "openbeacon-proto.h"
#include "display.h"
/* OpenBeacon packet */ /* OpenBeacon packet */
static TBeaconEnvelope g_Beacon; static TBeaconEnvelope g_Beacon;
/* Default TEA encryption key of the tag - MUST CHANGE ! */ /* Default TEA encryption key of the tag - MUST CHANGE ! */
static const uint32_t xxtea_key[4] = static const uint32_t xxtea_key[4] =
{ 0x00112233, 0x44556677, 0x8899AABB, 0xCCDDEEFF }; //{ 0x00112233, 0x44556677, 0x8899AABB, 0xCCDDEEFF };
{ 0xb4595344, 0xd3e119b6, 0xa814d0ec, 0xeff5a24e };
/* set nRF24L01 broadcast mac */ /* set nRF24L01 broadcast mac */
static const unsigned char broadcast_mac[NRF_MAX_MAC_SIZE] = static const unsigned char broadcast_mac[NRF_MAX_MAC_SIZE] =
@ -196,7 +198,7 @@ void nRF_Task(void *pvParameters)
/* Initialize OpenBeacon nRF24L01 interface */ /* Initialize OpenBeacon nRF24L01 interface */
if (!nRFAPI_Init(81, broadcast_mac, sizeof(broadcast_mac), 0)) if (!nRFAPI_Init(81, broadcast_mac, sizeof(broadcast_mac), 0))
/* bail out if can't initialize */ /* bail out if can't initialize */
// for (;;) for (;;)
{ {
pin_led(GPIO_LED0 | GPIO_LED1); pin_led(GPIO_LED0 | GPIO_LED1);
vTaskDelay(500 / portTICK_RATE_MS); vTaskDelay(500 / portTICK_RATE_MS);
@ -349,6 +351,9 @@ int main(void)
/* wait on boot - debounce */ /* wait on boot - debounce */
for (i = 0; i < 2000000; i++) for (i = 0; i < 2000000; i++)
; ;
//pmu_off(0);
lcdInit();
/* initialize pins */ /* initialize pins */
pin_init(); pin_init();
/* Init SPI */ /* Init SPI */

View File

@ -29,9 +29,10 @@
#include "nRF_CMD.h" #include "nRF_CMD.h"
#include "nRF_API.h" #include "nRF_API.h"
#ifndef NRF_RFOPTIONS //#ifndef NRF_RFOPTIONS
//#define NRF_RFOPTIONS 0x99
#define NRF_RFOPTIONS 0x09 #define NRF_RFOPTIONS 0x09
#endif /*NRF_RFOPTIONS */ //#endif /*NRF_RFOPTIONS */
// set broadcast MAC to 'BCAST' // set broadcast MAC to 'BCAST'
const uint8_t rfbroadcast_mac[NRF_MAX_MAC_SIZE] = { 'T', 'S', 'A', 'C', 'B' }; const uint8_t rfbroadcast_mac[NRF_MAX_MAC_SIZE] = { 'T', 'S', 'A', 'C', 'B' };
@ -91,13 +92,21 @@ nRFAPI_Init (uint8_t channel,
const uint8_t * mac, uint8_t mac_size, uint8_t features) const uint8_t * mac, uint8_t mac_size, uint8_t features)
{ {
uint8_t i; uint8_t i;
// init IO layer of nRF24L01 // init IO layer of nRF24L01
nRFCMD_Init (); nRFCMD_Init ();
/* wait for nRF to boot */ /* wait for nRF to boot */
vTaskDelay(10 / portTICK_RATE_MS); vTaskDelay(10 / portTICK_RATE_MS);
//nRFCMD_RegWriteStatusRead (CONFIG | WRITE_REG, 0x2);
// set selected channel
//nRFAPI_SetChannel (channel);
// set Tx power
//nRFAPI_SetTxPower (3);
//nRFCMD_CE(1);
//while(1);
// check validity // check validity
if (mac_size < 3 || mac_size > 5 || !nRFAPI_DetectChip ()) if (mac_size < 3 || mac_size > 5 || !nRFAPI_DetectChip ())
return 0; return 0;

View File

@ -26,10 +26,10 @@
/* IO definitions */ /* IO definitions */
#define BUTTON0_PORT 2 #define BUTTON0_PORT 2
#define BUTTON0_BIT 7 #define BUTTON0_BIT 7
#define LED0_PORT 2 #define LED0_PORT 1
#define LED0_BIT 5 #define LED0_BIT 11
#define LED1_PORT 2 #define LED1_PORT 1
#define LED1_BIT 4 #define LED1_BIT 7
#define CPU_MODE_PMU_PORT 2 #define CPU_MODE_PMU_PORT 2
#define CPU_MODE_PMU_BIT 8 #define CPU_MODE_PMU_BIT 8