From 422088690f8c39ae35384a549b571ba3fea22a4b Mon Sep 17 00:00:00 2001 From: Kevin Townsend Date: Sat, 28 Jan 2012 04:03:04 +0100 Subject: [PATCH] Minor fixes --- .../LPC1343 Workspace.workspace.session | 44 ++++++++-- build/crossworks/LPC1343_CodeBase.hzp | 13 ++- build/crossworks/LPC1343_CodeBase.hzs | 15 ++-- core/i2c/i2c.h | 2 +- drivers/lcd/bitmap/ssd1306/ssd1306.c | 17 ++-- drivers/lcd/bitmap/ssd1306/ssd1306.h | 2 +- drivers/sensors/pn532/pn532_bus.h | 6 +- main.c | 8 +- projectconfig.h | 84 ++++++++++++++++++- sysinit.c | 2 +- 10 files changed, 154 insertions(+), 39 deletions(-) diff --git a/build/codelite/LPC1343 Workspace.workspace.session b/build/codelite/LPC1343 Workspace.workspace.session index fce93d4..7b19ea7 100644 --- a/build/codelite/LPC1343 Workspace.workspace.session +++ b/build/codelite/LPC1343 Workspace.workspace.session @@ -1,22 +1,48 @@ - + - - - - - - - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build/crossworks/LPC1343_CodeBase.hzp b/build/crossworks/LPC1343_CodeBase.hzp index b4ad348..5a6c270 100644 --- a/build/crossworks/LPC1343_CodeBase.hzp +++ b/build/crossworks/LPC1343_CodeBase.hzp @@ -176,6 +176,9 @@ + + + @@ -218,10 +221,13 @@ - + + + + + - @@ -295,6 +301,9 @@ + + + diff --git a/build/crossworks/LPC1343_CodeBase.hzs b/build/crossworks/LPC1343_CodeBase.hzs index 70f8d54..b11be97 100644 --- a/build/crossworks/LPC1343_CodeBase.hzs +++ b/build/crossworks/LPC1343_CodeBase.hzs @@ -9,7 +9,7 @@ - + @@ -24,6 +24,10 @@ + + + + @@ -59,12 +63,7 @@ - - - - - - + - + diff --git a/core/i2c/i2c.h b/core/i2c/i2c.h index 4e700a4..2064351 100644 --- a/core/i2c/i2c.h +++ b/core/i2c/i2c.h @@ -39,7 +39,7 @@ #define FAST_MODE_PLUS 0 -#define I2C_BUFSIZE 16 +#define I2C_BUFSIZE 32 #define MAX_TIMEOUT 0x00FFFFFF #define I2CMASTER 0x01 diff --git a/drivers/lcd/bitmap/ssd1306/ssd1306.c b/drivers/lcd/bitmap/ssd1306/ssd1306.c index 0766e67..6aa038a 100644 --- a/drivers/lcd/bitmap/ssd1306/ssd1306.c +++ b/drivers/lcd/bitmap/ssd1306/ssd1306.c @@ -178,7 +178,7 @@ void ssd1306Init(uint8_t vccstate) CMD(SSD1306_SETDISPLAYCLOCKDIV); // 0xD5 CMD(0x80); // the suggested ratio 0x80 CMD(SSD1306_SETMULTIPLEX); // 0xA8 - CMD(0x1F); + CMD(0x1F); // 31 CMD(SSD1306_SETDISPLAYOFFSET); // 0xD3 CMD(0x0); // no offset CMD(SSD1306_SETSTARTLINE | 0x0); // line #0 @@ -187,6 +187,8 @@ void ssd1306Init(uint8_t vccstate) { CMD(0x10) } else { CMD(0x14) } + CMD(SSD1306_MEMORYMODE); // 0x20 + CMD(0x00); // 0x0 act like ks0108 CMD(SSD1306_SEGREMAP | 0x1); CMD(SSD1306_COMSCANDEC); CMD(SSD1306_SETCOMPINS); // 0xDA @@ -202,7 +204,7 @@ void ssd1306Init(uint8_t vccstate) else { CMD(0xF1) } CMD(SSD1306_SETVCOMDETECT); // 0xDB - CMD(0x40); // 0x20 is default? + CMD(0x40); CMD(SSD1306_DISPLAYALLON_RESUME); // 0xA4 CMD(SSD1306_NORMALDISPLAY); // 0xA6 #endif @@ -213,7 +215,7 @@ void ssd1306Init(uint8_t vccstate) CMD(SSD1306_SETDISPLAYCLOCKDIV); // 0xD5 CMD(0x80); // the suggested ratio 0x80 CMD(SSD1306_SETMULTIPLEX); // 0xA8 - CMD(0x3F); + CMD(0x3F); // 63 CMD(SSD1306_SETDISPLAYOFFSET); // 0xD3 CMD(0x0); // no offset CMD(SSD1306_SETSTARTLINE | 0x0); // line #0 @@ -222,6 +224,8 @@ void ssd1306Init(uint8_t vccstate) { CMD(0x10) } else { CMD(0x14) } + CMD(SSD1306_MEMORYMODE); // 0x20 + CMD(0x00); // 0x0 act like ks0108 CMD(SSD1306_SEGREMAP | 0x1); CMD(SSD1306_COMSCANDEC); CMD(SSD1306_SETCOMPINS); // 0xDA @@ -237,7 +241,7 @@ void ssd1306Init(uint8_t vccstate) else { CMD(0xF1) } CMD(SSD1306_SETVCOMDETECT); // 0xDB - CMD(0x40); // 0x20 is default? + CMD(0x40); CMD(SSD1306_DISPLAYALLON_RESUME); // 0xA4 CMD(SSD1306_NORMALDISPLAY); // 0xA6 #endif @@ -388,10 +392,7 @@ void ssd1306DrawString(uint16_t x, uint16_t y, char* text, struct FONT_DEF font) #include "drivers/lcd/smallfonts.h" // Configure the pins and initialise the LCD screen - ssd1306Init(); - - // Enable the backlight - ssd1306BLEnable(); + ssd1306Init(SSD1306_INTERNALVCC); // Continually write some text, scrolling upward one line each time while (1) diff --git a/drivers/lcd/bitmap/ssd1306/ssd1306.h b/drivers/lcd/bitmap/ssd1306/ssd1306.h index d9e9960..4bb1853 100644 --- a/drivers/lcd/bitmap/ssd1306/ssd1306.h +++ b/drivers/lcd/bitmap/ssd1306/ssd1306.h @@ -112,8 +112,8 @@ #define SSD1306_COMSCANDEC 0xC8 #define SSD1306_SEGREMAP 0xA0 #define SSD1306_CHARGEPUMP 0x8D -#define SSD1306_INTERNALVCC 0x1 #define SSD1306_EXTERNALVCC 0x1 +#define SSD1306_INTERNALVCC 0x2 #define SSD1306_SWITCHCAPVCC 0x2 // Initialisation/Config Prototypes diff --git a/drivers/sensors/pn532/pn532_bus.h b/drivers/sensors/pn532/pn532_bus.h index 1d578cc..a322933 100644 --- a/drivers/sensors/pn532/pn532_bus.h +++ b/drivers/sensors/pn532/pn532_bus.h @@ -10,7 +10,8 @@ #include "projectconfig.h" #include "pn532.h" -#define PN532_BUS_UART +// #define PN532_BUS_UART +#define PN532_BUS_I2C #define PN532_RSTPD_PORT (2) #define PN532_RSTPD_PIN (2) @@ -22,7 +23,10 @@ #define PN532_EXTENDED_FRAME__DATA_MAX_LEN (264) #define PN532_EXTENDED_FRAME__OVERHEAD (11) #define PN532_BUFFER_LEN (PN532_EXTENDED_FRAME__DATA_MAX_LEN + PN532_EXTENDED_FRAME__OVERHEAD) + #define PN532_UART_BAUDRATE (115200) +#define PN532_I2C_ADDRESS (0x48) +#define PN532_I2C_READBIT (0x01) // Generic interface for the different serial buses available on the PN532 void pn532_bus_HWInit(void); diff --git a/main.c b/main.c index dbae27d..8cff6f6 100644 --- a/main.c +++ b/main.c @@ -43,9 +43,6 @@ #include "core/gpio/gpio.h" #include "core/systick/systick.h" -#include "drivers/lcd/tft/hw/ssd1351.h" -#include "drivers/lcd/tft/drawing.h" - #ifdef CFG_INTERFACE #include "core/cmd/cmd.h" #endif @@ -63,9 +60,6 @@ int main(void) uint32_t currentSecond, lastSecond; currentSecond = lastSecond = 0; - - lcdInit(); - lcdTest(); while (1) { @@ -74,7 +68,7 @@ int main(void) if (currentSecond != lastSecond) { lastSecond = currentSecond; - gpioSetValue(CFG_LED_PORT, CFG_LED_PIN, ~(gpioGetValue(CFG_LED_PORT, CFG_LED_PIN))); + gpioSetValue(CFG_LED_PORT, CFG_LED_PIN, !(gpioGetValue(CFG_LED_PORT, CFG_LED_PIN))); } // Poll for CLI input if CFG_INTERFACE is enabled in projectconfig.h diff --git a/projectconfig.h b/projectconfig.h index d25de0f..e677c80 100644 --- a/projectconfig.h +++ b/projectconfig.h @@ -116,6 +116,7 @@ // #define CFG_BRD_LPC1343_TFTLCDSTANDALONE_USB // #define CFG_BRD_LPC1343_TFTLCDSTANDALONE_UART // #define CFG_BRD_LPC1343_802154USBSTICK + // #define CFG_BRD_LPC1343_OLIMEX_P /*=========================================================================*/ @@ -283,6 +284,11 @@ #define CFG_UART_BAUDRATE (115200) #define CFG_UART_BUFSIZE (512) #endif + + #ifdef CFG_BRD_LPC1343_OLIMEX_P + #define CFG_UART_BAUDRATE (115200) + #define CFG_UART_BUFSIZE (512) + #endif /*=========================================================================*/ @@ -313,6 +319,11 @@ // #define CFG_SSP0_SCKPIN_2_11 #define CFG_SSP0_SCKPIN_0_6 #endif + + #ifdef CFG_BRD_LPC1343_OLIMEX_P + #define CFG_SSP0_SCKPIN_2_11 + // #define CFG_SSP0_SCKPIN_0_6 + #endif /*=========================================================================*/ @@ -353,6 +364,13 @@ #define CFG_LED_ON (0) #define CFG_LED_OFF (1) #endif + + #ifdef CFG_BRD_LPC1343_OLIMEX_P + #define CFG_LED_PORT (3) + #define CFG_LED_PIN (2) + #define CFG_LED_ON (0) + #define CFG_LED_OFF (1) + #endif /*=========================================================================*/ @@ -407,6 +425,13 @@ #define CFG_SDCARD_CDPORT (3) #define CFG_SDCARD_CDPIN (0) #endif + + #ifdef CFG_BRD_LPC1343_OLIMEX_P + // #define CFG_SDCARD + #define CFG_SDCARD_READONLY (1) // Must be 0 or 1 + #define CFG_SDCARD_CDPORT (3) + #define CFG_SDCARD_CDPIN (0) + #endif /*=========================================================================*/ @@ -473,6 +498,14 @@ #define CFG_USBCDC_INITTIMEOUT (5000) #define CFG_USBCDC_BUFFERSIZE (256) #endif + + #ifdef CFG_BRD_LPC1343_OLIMEX_P + // #define CFG_USBHID + #define CFG_USBCDC + #define CFG_USBCDC_BAUDRATE (115200) + #define CFG_USBCDC_INITTIMEOUT (5000) + #define CFG_USBCDC_BUFFERSIZE (256) + #endif /*=========================================================================*/ @@ -519,6 +552,12 @@ #define CFG_PRINTF_USBCDC #define CFG_PRINTF_NEWLINE "\r\n" #endif + + #ifdef CFG_BRD_LPC1343_OLIMEX_P + // #define CFG_PRINTF_UART + #define CFG_PRINTF_USBCDC + #define CFG_PRINTF_NEWLINE "\r\n" + #endif /*=========================================================================*/ @@ -640,6 +679,19 @@ #define CFG_INTERFACE_SHORTERRORS (0) #define CFG_INTERFACE_CONFIRMREADY (0) #endif + + #ifdef CFG_BRD_LPC1343_OLIMEX_P + #define CFG_INTERFACE + #define CFG_INTERFACE_MAXMSGSIZE (256) + #define CFG_INTERFACE_PROMPT "LPC-P1343 >> " + #define CFG_INTERFACE_SILENTMODE (0) + #define CFG_INTERFACE_DROPCR (0) + #define CFG_INTERFACE_ENABLEIRQ (0) + #define CFG_INTERFACE_IRQPORT (0) + #define CFG_INTERFACE_IRQPIN (7) + #define CFG_INTERFACE_SHORTERRORS (0) + #define CFG_INTERFACE_CONFIRMREADY (0) + #endif /*=========================================================================*/ @@ -710,6 +762,11 @@ #define CFG_I2CEEPROM #define CFG_I2CEEPROM_SIZE (3072) #endif + + #ifdef CFG_BRD_LPC1343_OLIMEX_P + // #define CFG_I2CEEPROM + #define CFG_I2CEEPROM_SIZE (3072) + #endif /*=========================================================================*/ @@ -839,6 +896,16 @@ #define CFG_CHIBI_PROMISCUOUS (0) #define CFG_CHIBI_BUFFERSIZE (1024) #endif + + #ifdef CFG_BRD_LPC1343_OLIMEX_P + // #define CFG_CHIBI + #define CFG_CHIBI_MODE (0) // OQPSK_868MHZ + #define CFG_CHIBI_POWER (0xE9) // CHB_PWR_EU2_3DBM + #define CFG_CHIBI_CHANNEL (0) // 868-868.6 MHz + #define CFG_CHIBI_PANID (0x1234) + #define CFG_CHIBI_PROMISCUOUS (0) + #define CFG_CHIBI_BUFFERSIZE (128) + #endif /*=========================================================================*/ @@ -902,6 +969,13 @@ #define CFG_TFTLCD_TS_DEFAULTTHRESHOLD (50) #define CFG_TFTLCD_TS_KEYPADDELAY (100) #endif + + #ifdef CFG_BRD_LPC1343_OLIMEX_P + // #define CFG_TFTLCD + #define CFG_TFTLCD_INCLUDESMALLFONTS (0) + #define CFG_TFTLCD_TS_DEFAULTTHRESHOLD (50) + #define CFG_TFTLCD_TS_KEYPADDELAY (100) + #endif /*=========================================================================*/ @@ -959,7 +1033,12 @@ =========================================================================*/ -#if !defined CFG_BRD_LPC1343_REFDESIGN && !defined CFG_BRD_LPC1343_REFDESIGN_MINIMAL && !defined CFG_BRD_LPC1343_TFTLCDSTANDALONE_USB && !defined CFG_BRD_LPC1343_TFTLCDSTANDALONE_UART && !defined CFG_BRD_LPC1343_802154USBSTICK +#if !defined CFG_BRD_LPC1343_REFDESIGN && \ + !defined CFG_BRD_LPC1343_REFDESIGN_MINIMAL && \ + !defined CFG_BRD_LPC1343_TFTLCDSTANDALONE_USB && \ + !defined CFG_BRD_LPC1343_TFTLCDSTANDALONE_UART && \ + !defined CFG_BRD_LPC1343_802154USBSTICK && \ + !defined CFG_BRD_LPC1343_OLIMEX_P #error "You must defined a target board (CFG_BRD_LPC1343_REFDESIGN or CFG_BRD_LPC1343_REFDESIGN_MINIMAL or CFG_BRD_LPC1343_TFTLCDSTANDALONE or CFG_BRD_LPC1343_TFTLCDSTANDALONE_UART or CFG_BRD_LPC1343_802154USBSTICK)" #endif @@ -1017,6 +1096,9 @@ #ifdef CFG_SSD1306 #error "CFG_TFTLCD and CFG_SSD1306 can not be defined at the same time." #endif + #ifdef CFG_SHARPMEM + #error "CFG_TFTLCD and CFG_SHARPMEM can not be defined at the same time." + #endif #ifdef CFG_PWM #error "CFG_TFTLCD and CFG_PWM can not be defined at the same time since they both use pin 1.9." #endif diff --git a/sysinit.c b/sysinit.c index 4ce74dd..a3834b6 100644 --- a/sysinit.c +++ b/sysinit.c @@ -195,7 +195,7 @@ void systemInit() // Initialise the SSD1306 OLED display #ifdef CFG_SSD1306 - ssd1306Init(SSD1306_SWITCHCAPVCC); + ssd1306Init(SSD1306_INTERNALVCC); ssd1306ClearScreen(); // Clear the screen #endif -- 2.20.1