From d537298fdd7d39e4cb0e74e8e6d227245d638afe Mon Sep 17 00:00:00 2001 From: Kevin Townsend Date: Wed, 13 Jul 2011 02:33:01 +0200 Subject: [PATCH] Added backlight, reset, triangle and corner commands --- ChangeLog.txt | 5 +- Makefile | 3 +- build/codelite/LPC1343 Workspace.tags | Bin 136192 -> 141312 bytes .../LPC1343 Workspace.workspace.session | 20 +-- build/codelite/LPC1343_CodeBase.project | 2 + build/crossworks/LPC1343_CodeBase.hzp | 24 +++- build/crossworks/LPC1343_CodeBase.hzs | 29 +++-- core/gpio/gpio.c | 27 ++-- core/gpio/gpio.h | 3 +- core/usbcdc/cdcuser.c | 109 ++++++++++------ core/usbcdc/cdcuser.h | 2 +- core/usbcdc/usbcfg.h | 4 +- core/usbcdc/usbcore.c | 8 +- core/usbcdc/usbcore.h | 6 - core/usbcdc/usbdesc.c | 29 ++--- core/usbcdc/usbhw.c | 117 +++++++----------- core/usbcdc/usbuser.c | 3 +- drivers/chibi/chb_drvr.c | 2 +- drivers/eeprom/mcp24aa/mcp24aa.c | 4 +- drivers/lcd/bitmap/ssd1306/ssd1306.c | 12 +- drivers/lcd/bitmap/st7565/st7565.c | 12 +- drivers/lcd/tft/drawing.c | 80 ++++++++++++ drivers/lcd/tft/drawing.h | 9 ++ drivers/rtc/isl12022m/isl12022m.c | 3 +- drivers/sensors/lm75b/lm75b.c | 4 +- drivers/sensors/tcs3414/tcs3414.c | 5 +- drivers/sensors/tsl2561/tsl2561.c | 5 +- lpc134x.h | 16 +-- main.c | 22 ---- project/cmd_tbl.h | 4 + project/commands/cmd_reset.c | 60 +++++++++ project/commands/drawing/cmd_backlight.c | 65 ++++++++++ project/commands/drawing/cmd_roundedcorner.c | 85 +++++++++++++ project/commands/drawing/cmd_triangle.c | 85 +++++++++++++ projectconfig.h | 27 +++- sysdefs.h | 5 + sysinit.c | 7 ++ tools/testfirmware/usbcli.bin | Bin 13026 -> 0 bytes 38 files changed, 674 insertions(+), 229 deletions(-) create mode 100644 project/commands/cmd_reset.c create mode 100644 project/commands/drawing/cmd_backlight.c create mode 100644 project/commands/drawing/cmd_roundedcorner.c create mode 100644 project/commands/drawing/cmd_triangle.c delete mode 100644 tools/testfirmware/usbcli.bin diff --git a/ChangeLog.txt b/ChangeLog.txt index 8338ec6..96d9ba5 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,8 +1,11 @@ v0.9.3 - Ongoing ================ +- Added drawCornerFilled() to drawing.c and LCD CLI +- Fixed a nasty bug with 'gpioInterruptEvent' in the + gpioSetInterrupt function (core/gpio/gpio.c) - Add drawTriangle() and drawTriangleFilled() to - drawing.c + drawing.c and LCD CLI - Added cpuReset() to reset the board via AIRCR - Removed text input dialogue from LCD CLI ('T') to save a few KB. Command file still exists, just no diff --git a/Makefile b/Makefile index a211627..ef0296a 100644 --- a/Makefile +++ b/Makefile @@ -26,12 +26,13 @@ VPATH += project/commands OBJS += cmd_chibi_addr.o cmd_chibi_tx.o OBJS += cmd_i2ceeprom_read.o cmd_i2ceeprom_write.o cmd_lm75b_gettemp.o OBJS += cmd_reset.o cmd_sd_dir.o cmd_sysinfo.o cmd_uart.o +OBJS += cmd_roundedcorner.o VPATH += project/commands/drawing OBJS += cmd_backlight.o cmd_bmp.o cmd_button.o cmd_calibrate.o OBJS += cmd_circle.o cmd_clear.o cmd_line.o cmd_orientation.o OBJS += cmd_pixel.o cmd_progress.o cmd_rectangle.o cmd_text.o -OBJS += cmd_textw.o cmd_tsthreshhold.o cmd_tswait.o +OBJS += cmd_textw.o cmd_tsthreshhold.o cmd_tswait.o cmd_triangle.o ########################################################################## # Optional driver files diff --git a/build/codelite/LPC1343 Workspace.tags b/build/codelite/LPC1343 Workspace.tags index dfffc1d7cdd27bd0e27d4ee739b2e59a82344c91..0006aac5ccacf1b4a025f475f276f9f5aab5ae3f 100644 GIT binary patch delta 1648 zcmb7EZA_C_6u!?nZ)vdEn=wLd-=%Vb0@rPL;*_biYpd)HBRLl~y`=WKN`(@I+={fh@ z^E~I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i2`Qpw|EvTXD>f^_wIW8}Ek=US%jci>^FHu- zKF{+$nJ=x(dsbH%OHW0v_ygzjDD#n6Q}tMNs3$_>odPT3Q%d<%t&$IABmd@Gti%X1 zSfU11tsS%;HtLPm)%I6ktkju8F4CPv^dO|S#`u)STWhqI%{>KmJPDsC_@vQV@n7$m zMa)N@&d%pHon4GN1njQMn_=3AJ2t_i?+tO2UDsIMAGz)?T|bh}+y9_CsN6cD-c>m@q=wa~nuLiEVkkudHAtZaZRkc1au~ueMlnf~A;wtB1Z$XL z3)|Su9_Bd2VUBWAObJO$N+lsRl9Co_lWyseoD9jZjLPpWlewd_?Jx(@*PfSG$3L*& z9JAmZI6AgY`p1nuAuq~iaQje(H%K<|vb-+$4+O1ZV1u14sdJ7cF%8d0E@-FzbqluP zRIUleJgHCv+MC99J3SVi8R4^wt%%lX_t$OL_ZM>b!cpodcn(MilNj7sYUt|Y0-)1jQ z^J8A*H@wOT{wW>_N>rA~1F}l0rCy#>XJnteBKkl(?sT`$mni29Q|AK`=B~ZZCL5C} z_36!CR^5DA=e*yJyWvcCU^kphCtix1CZ-gooWMDphO5Ox&eR|RrsY#{<<=n`*n(o` z&}Y~w|LWM6yMSK`ob}(~BxgI(v$J2Bm5P;Y-~slzUQfz$Ny=+-(e-38oyrk>o>v%Q zTyX`fxRpdGWFgD7cN|L!q?6^6l@oGSF3E^Y91mJ_%CF;s zXMskK)hA;N=&rkH=|}!R{VY|-x#7BF g+!_@RZ;6zDCTmT(DHsb(NLWeOT_q?wT*M#$0fcfKkpKVy diff --git a/build/codelite/LPC1343 Workspace.workspace.session b/build/codelite/LPC1343 Workspace.workspace.session index 0a04b08..6d56121 100644 --- a/build/codelite/LPC1343 Workspace.workspace.session +++ b/build/codelite/LPC1343 Workspace.workspace.session @@ -1,18 +1,24 @@ - + - - - + + + - - - + + + + + + + + + diff --git a/build/codelite/LPC1343_CodeBase.project b/build/codelite/LPC1343_CodeBase.project index 582d2f6..b5f9df1 100644 --- a/build/codelite/LPC1343_CodeBase.project +++ b/build/codelite/LPC1343_CodeBase.project @@ -276,6 +276,8 @@ + + diff --git a/build/crossworks/LPC1343_CodeBase.hzp b/build/crossworks/LPC1343_CodeBase.hzp index c2466de..4085d03 100644 --- a/build/crossworks/LPC1343_CodeBase.hzp +++ b/build/crossworks/LPC1343_CodeBase.hzp @@ -1,5 +1,5 @@ - + @@ -81,17 +81,24 @@ + + + + + + + + - @@ -99,11 +106,15 @@ + + + + + - @@ -337,13 +348,18 @@ + + - + + + + diff --git a/build/crossworks/LPC1343_CodeBase.hzs b/build/crossworks/LPC1343_CodeBase.hzs index 493c96b..e88fa52 100644 --- a/build/crossworks/LPC1343_CodeBase.hzs +++ b/build/crossworks/LPC1343_CodeBase.hzs @@ -1,7 +1,16 @@ - + + + + + + + + + + @@ -19,12 +28,9 @@ - - - - + @@ -41,10 +47,10 @@ - - - + + + @@ -56,6 +62,9 @@ - - + + + + + diff --git a/core/gpio/gpio.c b/core/gpio/gpio.c index 3809a5e..9c84655 100644 --- a/core/gpio/gpio.c +++ b/core/gpio/gpio.c @@ -47,6 +47,10 @@ volatile uint32_t chibi_counter = 0; #endif +#ifdef CFG_ALTRESET +#include "core/cpu/cpu.h" +#endif + static bool _gpioInitialised = false; /**************************************************************************/ @@ -75,6 +79,15 @@ void PIOINT1_IRQHandler(void) { uint32_t regVal; +#if defined CFG_ALTRESET && CFG_ALTRESET_PORT == 1 + regVal = gpioIntStatus(CFG_ALTRESET_PORT, CFG_ALTRESET_PIN); + if (regVal) + { + // Cause a reset and wait + cpuReset(); + } +#endif + #ifdef CFG_CHIBI // Check for interrupt on 1.8 regVal = gpioIntStatus(1, 8); @@ -312,9 +325,9 @@ void gpioSetInterrupt (uint32_t portNum, uint32_t bitPos, gpioInterruptSense_t s if (!_gpioInitialised) gpioInit(); // Get the appropriate register (handled this way to optimise code size) - REG32 *gpiois = &GPIO_GPIO0IS; - REG32 *gpioibe = &GPIO_GPIO0IBE; - REG32 *gpioiev = &GPIO_GPIO0IEV; + REG32 *gpiois = &GPIO_GPIO0IS; // Interrupt sense (edge or level sensitive) + REG32 *gpioibe = &GPIO_GPIO0IBE; // Interrupt both edges (0 = int controlled by GPIOIEV, 1 = both edges trigger interrupt) + REG32 *gpioiev = &GPIO_GPIO0IEV; // 0 = falling edge or low, 1 = rising edge or high (depending on GPIOIS) switch (portNum) { case 0: @@ -339,18 +352,18 @@ void gpioSetInterrupt (uint32_t portNum, uint32_t bitPos, gpioInterruptSense_t s break; } - if (gpioInterruptSense_Edge) + + if (sense == gpioInterruptSense_Edge) { *gpiois &= ~(0x1<> 0) & 0xFF; EP0Buf[1] = (CDC_LineCoding.dwDTERate >> 8) & 0xFF; EP0Buf[2] = (CDC_LineCoding.dwDTERate >> 16) & 0xFF; @@ -275,12 +284,22 @@ uint32_t CDC_SendBreak (unsigned short wDurationOfBreak) { Parameters: none Return Value: none *---------------------------------------------------------------------------*/ -void CDC_BulkIn(void) -{ -// int numBytesRead, numBytesAvail; -// -// // ToDo: Modify BulkIn to send incoming data to USB -// +void CDC_BulkIn(void) { + //int numBytesRead, numBytesAvail; + +// uint8_t frame[64]; +// uint32_t bytesRead = 0; +// if (cdcBufferDataPending()) +// { +// // Read up to 64 bytes +// bytesRead = cdcBufferReadLen(frame, 64); +// if (bytesRead > 0) +// { +// USB_WriteEP (CDC_DEP_IN, frame, bytesRead); +// } +// } + + // ser_AvailChar (&numBytesAvail); // // // ... add code to check for overwrite @@ -294,8 +313,6 @@ void CDC_BulkIn(void) // else { // CDC_DepInEmpty = 1; // } -// -// } @@ -304,8 +321,7 @@ void CDC_BulkIn(void) Parameters: none Return Value: none *---------------------------------------------------------------------------*/ -void CDC_BulkOut(void) -{ +void CDC_BulkOut(void) { int numBytesRead; // get data from USB into intermediate buffer @@ -315,6 +331,7 @@ void CDC_BulkOut(void) // store data in a buffer to transmit it over serial interface CDC_WrOutBuf ((char *)&BulkBufOut[0], &numBytesRead); + } @@ -323,9 +340,19 @@ void CDC_BulkOut(void) Parameters: none Return Value: SerialState as defined in usbcdc11.pdf *---------------------------------------------------------------------------*/ -unsigned short CDC_GetSerialState (void) -{ +unsigned short CDC_GetSerialState (void) { +// unsigned short temp; + CDC_SerialState = 0; +// ser_LineState (&temp); +// +// if (temp & 0x8000) CDC_SerialState |= CDC_SERIAL_STATE_RX_CARRIER; +// if (temp & 0x2000) CDC_SerialState |= CDC_SERIAL_STATE_TX_CARRIER; +// if (temp & 0x0010) CDC_SerialState |= CDC_SERIAL_STATE_BREAK; +// if (temp & 0x4000) CDC_SerialState |= CDC_SERIAL_STATE_RING; +// if (temp & 0x0008) CDC_SerialState |= CDC_SERIAL_STATE_FRAMING; +// if (temp & 0x0004) CDC_SerialState |= CDC_SERIAL_STATE_PARITY; +// if (temp & 0x0002) CDC_SerialState |= CDC_SERIAL_STATE_OVERRUN; return (CDC_SerialState); } @@ -334,8 +361,8 @@ unsigned short CDC_GetSerialState (void) /*---------------------------------------------------------------------------- Send the SERIAL_STATE notification as defined in usbcdc11.pdf, 6.3.5. *---------------------------------------------------------------------------*/ -void CDC_NotificationIn (void) -{ +void CDC_NotificationIn (void) { + NotificationBuf[0] = 0xA1; // bmRequestType NotificationBuf[1] = CDC_NOTIFICATION_SERIAL_STATE; // bNotification (SERIAL_STATE) NotificationBuf[2] = 0x00; // wValue diff --git a/core/usbcdc/cdcuser.h b/core/usbcdc/cdcuser.h index 55cd910..7512157 100644 --- a/core/usbcdc/cdcuser.h +++ b/core/usbcdc/cdcuser.h @@ -50,7 +50,7 @@ extern void CDC_BulkOut (void); /* CDC Notification Callback Function */ extern void CDC_NotificationIn (void); -/* CDC Initialization Function */ +/* CDC Initializtion Function */ extern void CDC_Init (void); /* CDC prepare the SERAIAL_STATE */ diff --git a/core/usbcdc/usbcfg.h b/core/usbcdc/usbcfg.h index cad6c43..aa7ffde 100644 --- a/core/usbcdc/usbcfg.h +++ b/core/usbcdc/usbcfg.h @@ -101,7 +101,7 @@ #define USB_SUSPEND_EVENT 1 #define USB_RESUME_EVENT 1 #define USB_WAKEUP_EVENT 0 -#define USB_SOF_EVENT 1 +#define USB_SOF_EVENT 0 #define USB_ERROR_EVENT 0 #define USB_EP_EVENT 0x000B #define USB_CONFIGURE_EVENT 1 @@ -141,7 +141,7 @@ #define USB_ADC_CIF_NUM 0 #define USB_ADC_SIF1_NUM 1 #define USB_ADC_SIF2_NUM 2 -#define USB_CDC 1 +#define USB_CDC 1 #define USB_CDC_CIF_NUM 0 #define USB_CDC_DIF_NUM 1 #define USB_CDC_BUFSIZE CFG_USBCDC_BUFSIZE diff --git a/core/usbcdc/usbcore.c b/core/usbcdc/usbcore.c index fe09bbd..fe33aba 100644 --- a/core/usbcdc/usbcore.c +++ b/core/usbcdc/usbcore.c @@ -169,7 +169,6 @@ void USB_StatusOutStage (void) { static inline uint32_t USB_ReqGetStatus (void) { uint32_t n, m; - uint16_t* ep0 = (uint16_t __attribute__((packed)) *)EP0Buf; switch (SetupPacket.bmRequestType.BM.Recipient) { case REQUEST_TO_DEVICE: @@ -177,7 +176,7 @@ static inline uint32_t USB_ReqGetStatus (void) { break; case REQUEST_TO_INTERFACE: if ((USB_Configuration != 0) && (SetupPacket.wIndex.WB.L < USB_NumInterfaces)) { - *ep0 = 0; + *((uint16_t __attribute__((packed)) *)EP0Buf) = 0; EP0Data.pData = EP0Buf; } else { return (FALSE); @@ -187,7 +186,7 @@ static inline uint32_t USB_ReqGetStatus (void) { n = SetupPacket.wIndex.WB.L & 0x8F; m = (n & 0x80) ? ((1 << 16) << (n & 0x0F)) : (1 << n); if (((USB_Configuration != 0) || ((n & 0x0F) == 0)) && (USB_EndPointMask & m)) { - *ep0 = (USB_EndPointHalt & m) ? 1 : 0; + *((uint16_t __attribute__((packed)) *)EP0Buf) = (USB_EndPointHalt & m) ? 1 : 0; EP0Data.pData = EP0Buf; } else { return (FALSE); @@ -364,6 +363,7 @@ static inline uint32_t USB_ReqGetDescriptor (void) { return (TRUE); } + /* * Get Configuration USB Request * Parameters: None (global SetupPacket) @@ -376,6 +376,7 @@ static inline uint32_t USB_ReqGetConfiguration (void) { case REQUEST_TO_DEVICE: // Added cast to avoid warnings due to USB_Configuration being volatile (KTownsend) EP0Data.pData = (uint8_t *)&USB_Configuration; + //EP0Data.pData = &USB_Configuration; break; default: return (FALSE); @@ -562,6 +563,7 @@ static inline uint32_t USB_ReqSetInterface (void) { return (set); } + /* * USB Endpoint 0 Event Callback * Parameters: event diff --git a/core/usbcdc/usbcore.h b/core/usbcdc/usbcore.h index 5098be0..f9d9778 100644 --- a/core/usbcdc/usbcore.h +++ b/core/usbcdc/usbcore.h @@ -36,7 +36,6 @@ extern uint32_t USB_EndPointHalt; extern uint32_t USB_EndPointStall; extern uint8_t USB_AltSetting[USB_IF_NUM]; - /* USB Endpoint 0 Buffer */ extern uint8_t EP0Buf[USB_MAX_PACKET0]; @@ -80,9 +79,4 @@ static inline void UsbAddPtr(void **vpptr, uint32_t n) } - - - - - #endif /* __USBCORE_H__ */ diff --git a/core/usbcdc/usbdesc.c b/core/usbcdc/usbdesc.c index 6642e60..d523e89 100644 --- a/core/usbcdc/usbdesc.c +++ b/core/usbcdc/usbdesc.c @@ -20,6 +20,7 @@ * V1.00 Initial Version *---------------------------------------------------------------------------*/ #include "projectconfig.h" + #include "usb.h" #include "cdc.h" #include "usbcfg.h" @@ -144,39 +145,39 @@ const uint8_t USB_StringDescriptor[] = { /* Index 0x01: Manufacturer */ (13*2 + 2), /* bLength (13 Char + Type + lenght) */ USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType */ + 'N',0, + 'X',0, + 'P',0, + ' ',0, + 'S',0, + 'E',0, 'M',0, 'I',0, 'C',0, - 'R',0, 'O',0, - 'B',0, - 'U',0, - 'I',0, - 'L',0, + 'N',0, 'D',0, - 'E',0, - 'R',0, ' ',0, /* Index 0x02: Product */ (17*2 + 2), /* bLength ( 17 Char + Type + lenght) */ USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType */ + 'N',0, + 'X',0, + 'P',0, + ' ',0, 'L',0, 'P',0, 'C',0, '1',0, '3',0, - '4',0, - '3',0, + 'x',0, + 'x',0, ' ',0, + 'V',0, 'C',0, 'O',0, 'M',0, ' ',0, - 'P',0, - 'O',0, - 'R',0, - 'T',0, - ' ',0, /* Index 0x03: Serial Number */ (12*2 + 2), /* bLength (12 Char + Type + lenght) */ USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType */ diff --git a/core/usbcdc/usbhw.c b/core/usbcdc/usbhw.c index fdc88f1..88add23 100644 --- a/core/usbcdc/usbhw.c +++ b/core/usbcdc/usbhw.c @@ -19,7 +19,7 @@ * V1.20 Added USB_ClearEPBuf * V1.00 Initial Version *----------------------------------------------------------------------------*/ -#include "projectconfig.h" /* LPC13xx definitions */ +#include "projectconfig.h" #include "usb.h" #include "usbcfg.h" #include "usbreg.h" @@ -79,13 +79,12 @@ void USBIOClkConfig( void ) * Return Value: None */ -void delay (uint32_t length ) -{ +void delay (uint32_t length ) { uint32_t i; for ( i = 0; i < length; i++ ) { - __asm("nop"); + __asm volatile("nop"); } return; } @@ -98,8 +97,7 @@ void delay (uint32_t length ) * Return Value: Endpoint Physical Address */ -uint32_t EPAdr (uint32_t EPNum) -{ +uint32_t EPAdr (uint32_t EPNum) { uint32_t val; val = (EPNum & 0x0F) << 1; @@ -116,8 +114,8 @@ uint32_t EPAdr (uint32_t EPNum) * Return Value: None */ -void WrCmd (uint32_t cmd) -{ +void WrCmd (uint32_t cmd) { + USB_DEVINTCLR = CCEMTY_INT; USB_CMDCODE = cmd; while ((USB_DEVINTST & (CCEMTY_INT | DEV_STAT_INT)) == 0); @@ -131,8 +129,8 @@ void WrCmd (uint32_t cmd) * Return Value: None */ -void WrCmdDat (uint32_t cmd, uint32_t val) -{ +void WrCmdDat (uint32_t cmd, uint32_t val) { + WrCmd(cmd); WrCmd(val); } @@ -145,8 +143,8 @@ void WrCmdDat (uint32_t cmd, uint32_t val) * Return Value: None */ -void WrCmdEP (uint32_t EPNum, uint32_t cmd) -{ +void WrCmdEP (uint32_t EPNum, uint32_t cmd){ + WrCmd(CMD_SEL_EP(EPAdr(EPNum))); WrCmd(cmd); } @@ -158,8 +156,8 @@ void WrCmdEP (uint32_t EPNum, uint32_t cmd) * Return Value: Data Value */ -uint32_t RdCmdDat (uint32_t cmd) -{ +uint32_t RdCmdDat (uint32_t cmd) { + USB_DEVINTCLR = CCEMTY_INT | CDFULL_INT; USB_CMDCODE = cmd; while ((USB_DEVINTST & (CDFULL_INT | DEV_STAT_INT)) == 0); @@ -173,8 +171,8 @@ uint32_t RdCmdDat (uint32_t cmd) * Return Value: None */ -void USB_Init (void) -{ +void USB_Init (void) { + // Setup USB clock and pins USBIOClkConfig(); @@ -203,8 +201,7 @@ void USB_Init (void) * Return Value: None */ -void USB_Connect (uint32_t con) -{ +void USB_Connect (uint32_t con) { WrCmdDat(CMD_SET_DEV_STAT, DAT_WR_BYTE(con ? DEV_CON : 0)); } @@ -215,8 +212,8 @@ void USB_Connect (uint32_t con) * Return Value: None */ -void USB_Reset (void) -{ +void USB_Reset (void) { + USB_DEVINTCLR = 0x000FFFFF; /* Enable all eight(8) EPs, note: EP won't be ready until it's configured/enabled when device sending SetEPStatus command @@ -233,8 +230,7 @@ void USB_Reset (void) * Return Value: None */ -void USB_Suspend (void) -{ +void USB_Suspend (void) { /* Performed by Hardware */ } @@ -245,8 +241,7 @@ void USB_Suspend (void) * Return Value: None */ -void USB_Resume (void) -{ +void USB_Resume (void) { /* Performed by Hardware */ } @@ -257,10 +252,9 @@ void USB_Resume (void) * Return Value: None */ -void USB_WakeUp (void) -{ - if (USB_DeviceStatus & USB_GETSTATUS_REMOTE_WAKEUP) - { +void USB_WakeUp (void) { + + if (USB_DeviceStatus & USB_GETSTATUS_REMOTE_WAKEUP) { WrCmdDat(CMD_SET_DEV_STAT, DAT_WR_BYTE(DEV_CON)); } } @@ -272,8 +266,7 @@ void USB_WakeUp (void) * Return Value: None */ -void USB_WakeUpCfg (uint32_t cfg) -{ +void USB_WakeUpCfg (uint32_t cfg) { cfg = cfg; /* Not needed */ } @@ -284,8 +277,7 @@ void USB_WakeUpCfg (uint32_t cfg) * Return Value: None */ -void USB_SetAddress (uint32_t adr) -{ +void USB_SetAddress (uint32_t adr) { WrCmdDat(CMD_SET_ADDR, DAT_WR_BYTE(DEV_EN | adr)); /* Don't wait for next */ WrCmdDat(CMD_SET_ADDR, DAT_WR_BYTE(DEV_EN | adr)); /* Setup Status Phase */ } @@ -297,8 +289,8 @@ void USB_SetAddress (uint32_t adr) * Return Value: None */ -void USB_Configure (uint32_t cfg) -{ +void USB_Configure (uint32_t cfg) { + WrCmdDat(CMD_CFG_DEV, DAT_WR_BYTE(cfg ? CONF_DVICE : 0)); return; } @@ -310,8 +302,7 @@ void USB_Configure (uint32_t cfg) * Return Value: None */ -void USB_ConfigEP (USB_ENDPOINT_DESCRIPTOR *pEPD) -{ +void USB_ConfigEP (USB_ENDPOINT_DESCRIPTOR *pEPD) { return; } @@ -322,8 +313,7 @@ void USB_ConfigEP (USB_ENDPOINT_DESCRIPTOR *pEPD) * Return Value: None */ -void USB_DirCtrlEP (uint32_t dir) -{ +void USB_DirCtrlEP (uint32_t dir) { dir = dir; /* Not needed */ } @@ -336,8 +326,7 @@ void USB_DirCtrlEP (uint32_t dir) * Return Value: None */ -void USB_EnableEP (uint32_t EPNum) -{ +void USB_EnableEP (uint32_t EPNum) { WrCmdDat(CMD_SET_EP_STAT(EPAdr(EPNum)), DAT_WR_BYTE(0)); } @@ -350,8 +339,7 @@ void USB_EnableEP (uint32_t EPNum) * Return Value: None */ -void USB_DisableEP (uint32_t EPNum) -{ +void USB_DisableEP (uint32_t EPNum) { WrCmdDat(CMD_SET_EP_STAT(EPAdr(EPNum)), DAT_WR_BYTE(EP_STAT_DA)); } @@ -364,8 +352,7 @@ void USB_DisableEP (uint32_t EPNum) * Return Value: None */ -void USB_ResetEP (uint32_t EPNum) -{ +void USB_ResetEP (uint32_t EPNum) { WrCmdDat(CMD_SET_EP_STAT(EPAdr(EPNum)), DAT_WR_BYTE(0)); } @@ -378,8 +365,7 @@ void USB_ResetEP (uint32_t EPNum) * Return Value: None */ -void USB_SetStallEP (uint32_t EPNum) -{ +void USB_SetStallEP (uint32_t EPNum) { WrCmdDat(CMD_SET_EP_STAT(EPAdr(EPNum)), DAT_WR_BYTE(EP_STAT_ST)); } @@ -392,8 +378,7 @@ void USB_SetStallEP (uint32_t EPNum) * Return Value: None */ -void USB_ClrStallEP (uint32_t EPNum) -{ +void USB_ClrStallEP (uint32_t EPNum) { WrCmdDat(CMD_SET_EP_STAT(EPAdr(EPNum)), DAT_WR_BYTE(0)); } @@ -406,8 +391,7 @@ void USB_ClrStallEP (uint32_t EPNum) * Return Value: None */ -void USB_ClearEPBuf (uint32_t EPNum) -{ +void USB_ClearEPBuf (uint32_t EPNum) { WrCmdEP(EPNum, CMD_CLR_BUF); } @@ -421,30 +405,26 @@ void USB_ClearEPBuf (uint32_t EPNum) * Return Value: Number of bytes read */ -uint32_t USB_ReadEP (uint32_t EPNum, uint8_t *pData) -{ +uint32_t USB_ReadEP (uint32_t EPNum, uint8_t *pData) { uint32_t cnt, n; USB_CTRL = ((EPNum & 0x0F) << 2) | CTRL_RD_EN; /* 3 clock cycles to fetch the packet length from RAM. */ delay( 5 ); - do - { + do { cnt = USB_RXPLEN; } while ((cnt & PKT_DV) == 0); cnt &= PKT_LNGTH_MASK; - for (n = 0; n < (cnt + 3) / 4; n++) - { + for (n = 0; n < (cnt + 3) / 4; n++) { *((uint32_t __attribute__((packed)) *)pData) = USB_RXDATA; pData += 4; } USB_CTRL = 0; - if ((EPNum & 0x80) != 0x04) - { /* Non-Isochronous Endpoint */ + if ((EPNum & 0x80) != 0x04) { /* Non-Isochronous Endpoint */ WrCmdEP(EPNum, CMD_CLR_BUF); } @@ -462,8 +442,7 @@ uint32_t USB_ReadEP (uint32_t EPNum, uint8_t *pData) * Return Value: Number of bytes written */ -uint32_t USB_WriteEP (uint32_t EPNum, uint8_t *pData, uint32_t cnt) -{ +uint32_t USB_WriteEP (uint32_t EPNum, uint8_t *pData, uint32_t cnt) { uint32_t n; USB_CTRL = ((EPNum & 0x0F) << 2) | CTRL_WR_EN; @@ -471,8 +450,7 @@ uint32_t USB_WriteEP (uint32_t EPNum, uint8_t *pData, uint32_t cnt) delay( 5 ); USB_TXPLEN = cnt; - for (n = 0; n < (cnt + 3) / 4; n++) - { + for (n = 0; n < (cnt + 3) / 4; n++) { USB_TXDATA = *((uint32_t __attribute__((packed)) *)pData); pData += 4; } @@ -490,8 +468,7 @@ uint32_t USB_WriteEP (uint32_t EPNum, uint8_t *pData, uint32_t cnt) * Return Value: Frame Number */ -uint32_t USB_GetFrame (void) -{ +uint32_t USB_GetFrame (void) { uint32_t val; WrCmd(CMD_RD_FRAME); @@ -515,8 +492,7 @@ void USB_IRQHandler (void) USB_DEVINTCLR = disr; /* Device Status Interrupt (Reset, Connect change, Suspend/Resume) */ - if (disr & DEV_STAT_INT) - { + if (disr & DEV_STAT_INT) { WrCmd(CMD_GET_DEV_STAT); val = RdCmdDat(DAT_GET_DEV_STAT); /* Device Status */ if (val & DEV_RST) { /* Reset */ @@ -548,11 +524,10 @@ void USB_IRQHandler (void) #if USB_SOF_EVENT /* Start of Frame Interrupt */ - if (disr & FRAME_INT) - { + if (disr & FRAME_INT) { USB_DEVINTCLR = FRAME_INT; USB_SOF_Event(); - // SOFIRQCount++; + SOFIRQCount++; } #endif @@ -560,8 +535,7 @@ void USB_IRQHandler (void) /* NO error interrupt anymore, below code can be used as example to get error status from command engine. */ /* Error Interrupt */ - if (disr & ERR_INT) - { + if (disr & ERR_INT) { WrCmd(CMD_RD_ERR_STAT); val = RdCmdDat(DAT_RD_ERR_STAT); USB_Error_Event(val); @@ -602,5 +576,4 @@ void USB_IRQHandler (void) isr_end: return; } - #endif diff --git a/core/usbcdc/usbuser.c b/core/usbcdc/usbuser.c index 54f7b9e..6d1c660 100644 --- a/core/usbcdc/usbuser.c +++ b/core/usbcdc/usbuser.c @@ -182,8 +182,7 @@ void USB_EndPoint1 (uint32_t event) { * Parameter: event */ -void USB_EndPoint2 (uint32_t event) -{ +void USB_EndPoint2 (uint32_t event) { event = event; } diff --git a/drivers/chibi/chb_drvr.c b/drivers/chibi/chb_drvr.c index 4147725..fb78918 100644 --- a/drivers/chibi/chb_drvr.c +++ b/drivers/chibi/chb_drvr.c @@ -766,7 +766,7 @@ static void chb_radio_init() CHB_EINTPIN, gpioInterruptSense_Edge, // Edge-sensitive gpioInterruptEdge_Single, // Single edge - gpioInterruptEvent_ActiveHigh); // High triggers interrupt + gpioInterruptEvent_ActiveLow); // High triggers interrupt // enable interrupt gpioIntEnable (CHB_EINTPORT, diff --git a/drivers/eeprom/mcp24aa/mcp24aa.c b/drivers/eeprom/mcp24aa/mcp24aa.c index f7f981d..24d8975 100644 --- a/drivers/eeprom/mcp24aa/mcp24aa.c +++ b/drivers/eeprom/mcp24aa/mcp24aa.c @@ -108,8 +108,6 @@ extern volatile uint8_t I2CMasterBuffer[I2C_BUFSIZE]; extern volatile uint8_t I2CSlaveBuffer[I2C_BUFSIZE]; extern volatile uint32_t I2CReadLength, I2CWriteLength; -uint32_t i, timeout; - static bool _mcp24aaInitialised = false; /**************************************************************************/ @@ -164,6 +162,7 @@ mcp24aaError_e mcp24aaReadBuffer (uint16_t address, uint8_t *buffer, uint32_t bu // ToDo: Check if I2C is ready // Clear buffers + uint32_t i; for ( i = 0; i < I2C_BUFSIZE; i++ ) { I2CMasterBuffer[i] = 0x00; @@ -227,6 +226,7 @@ mcp24aaError_e mcp24aaWriteBuffer (uint16_t address, uint8_t *buffer, uint32_t b // ToDo: Check if I2C is ready // Clear write buffer + uint32_t i; for ( i = 0; i < I2C_BUFSIZE; i++ ) { I2CMasterBuffer[i] = 0x00; diff --git a/drivers/lcd/bitmap/ssd1306/ssd1306.c b/drivers/lcd/bitmap/ssd1306/ssd1306.c index 40d5a04..fce409b 100644 --- a/drivers/lcd/bitmap/ssd1306/ssd1306.c +++ b/drivers/lcd/bitmap/ssd1306/ssd1306.c @@ -64,7 +64,7 @@ void ssd1306SendByte(uint8_t byte); } while (0); #define DELAY(mS) do { systickDelay( mS / CFG_SYSTICK_DELAY_IN_MS ); } while(0); -uint8_t buffer[SSD1306_LCDWIDTH * SSD1306_LCDHEIGHT / 8]; +uint8_t _ssd1306buffer[SSD1306_LCDWIDTH * SSD1306_LCDHEIGHT / 8]; /**************************************************************************/ /* Private Methods */ @@ -223,7 +223,7 @@ void ssd1306DrawPixel(uint8_t x, uint8_t y) if ((x >= SSD1306_LCDWIDTH) || (y >= SSD1306_LCDHEIGHT)) return; - buffer[x+ (y/8)*SSD1306_LCDWIDTH] |= (1 << y%8); + _ssd1306buffer[x+ (y/8)*SSD1306_LCDWIDTH] |= (1 << y%8); } /**************************************************************************/ @@ -241,7 +241,7 @@ void ssd1306ClearPixel(uint8_t x, uint8_t y) if ((x >= SSD1306_LCDWIDTH) || (y >= SSD1306_LCDHEIGHT)) return; - buffer[x+ (y/8)*SSD1306_LCDWIDTH] &= ~(1 << y%8); + _ssd1306buffer[x+ (y/8)*SSD1306_LCDWIDTH] &= ~(1 << y%8); } /**************************************************************************/ @@ -259,7 +259,7 @@ void ssd1306ClearPixel(uint8_t x, uint8_t y) uint8_t ssd1306GetPixel(uint8_t x, uint8_t y) { if ((x >= SSD1306_LCDWIDTH) || (y >=SSD1306_LCDHEIGHT)) return 0; - return buffer[x+ (y/8)*SSD1306_LCDWIDTH] & (1 << y%8) ? 1 : 0; + return _ssd1306buffer[x+ (y/8)*SSD1306_LCDWIDTH] & (1 << y%8) ? 1 : 0; } /**************************************************************************/ @@ -269,7 +269,7 @@ uint8_t ssd1306GetPixel(uint8_t x, uint8_t y) /**************************************************************************/ void ssd1306ClearScreen() { - memset(buffer, 0, 1024); + memset(_ssd1306buffer, 0, 1024); } /**************************************************************************/ @@ -286,7 +286,7 @@ void ssd1306Refresh(void) uint16_t i; for (i=0; i<1024; i++) { - DATA(buffer[i]); + DATA(_ssd1306buffer[i]); } } diff --git a/drivers/lcd/bitmap/st7565/st7565.c b/drivers/lcd/bitmap/st7565/st7565.c index b0995ac..36707cb 100644 --- a/drivers/lcd/bitmap/st7565/st7565.c +++ b/drivers/lcd/bitmap/st7565/st7565.c @@ -54,7 +54,7 @@ void sendByte(uint8_t byte); #define DATA(d) do { gpioSetValue( ST7565_A0_PORT, ST7565_A0_PIN, 1 ); sendByte( d ); } while (0); #define DELAY(mS) do { systickDelay( mS / CFG_SYSTICK_DELAY_IN_MS ); } while(0); -uint8_t buffer[128*64/8]; +uint8_t _st7565buffer[128*64/8]; /**************************************************************************/ /* Private Methods */ @@ -257,7 +257,7 @@ void st7565SetBrightness(uint8_t val) /**************************************************************************/ void st7565ClearScreen(void) { - memset(&buffer, 0x00, 128*64/8); + memset(&_st7565buffer, 0x00, 128*64/8); } /**************************************************************************/ @@ -267,7 +267,7 @@ void st7565ClearScreen(void) /**************************************************************************/ void st7565Refresh(void) { - writeBuffer(buffer); + writeBuffer(_st7565buffer); } /**************************************************************************/ @@ -286,7 +286,7 @@ void st7565DrawPixel(uint8_t x, uint8_t y) return; // x is which column - buffer[x+ (y/8)*128] |= (1 << (7-(y%8))); + _st7565buffer[x+ (y/8)*128] |= (1 << (7-(y%8))); } /**************************************************************************/ @@ -305,7 +305,7 @@ void st7565ClearPixel(uint8_t x, uint8_t y) return; // x is which column - buffer[x+ (y/8)*128] &= ~(1 << (7-(y%8))); + _st7565buffer[x+ (y/8)*128] &= ~(1 << (7-(y%8))); } /**************************************************************************/ @@ -323,7 +323,7 @@ void st7565ClearPixel(uint8_t x, uint8_t y) uint8_t st7565GetPixel(uint8_t x, uint8_t y) { if ((x >= 128) || (y >= 64)) return 0; - return buffer[x+ (y/8)*128] & (1 << (7-(y%8))); + return _st7565buffer[x+ (y/8)*128] & (1 << (7-(y%8))); } /**************************************************************************/ diff --git a/drivers/lcd/tft/drawing.c b/drivers/lcd/tft/drawing.c index 201df6c..61a0135 100644 --- a/drivers/lcd/tft/drawing.c +++ b/drivers/lcd/tft/drawing.c @@ -649,6 +649,86 @@ void drawCircleFilled (uint16_t xCenter, uint16_t yCenter, uint16_t radius, uint } } +/**************************************************************************/ +/*! + @brief Draws a filled rounded corner + + @param[in] xCenter + The horizontal center of the circle + @param[in] yCenter + The vertical center of the circle + @param[in] radius + The circle's radius in pixels + @param[in] position + The position of the corner, which affects how it will + be rendered + @param[in] color + Color used when drawing +*/ +/**************************************************************************/ +void drawCornerFilled (uint16_t xCenter, uint16_t yCenter, uint16_t radius, drawCornerPosition_t position, uint16_t color) +{ + int16_t f = 1 - radius; + int16_t ddF_x = 1; + int16_t ddF_y = -2 * radius; + int16_t x = 0; + int16_t y = radius; + int16_t xc_px, yc_my, xc_mx, xc_py, yc_mx, xc_my; + int16_t lcdWidth = lcdGetWidth(); + + switch (position) + { + case DRAW_CORNERPOSITION_TOPRIGHT: + case DRAW_CORNERPOSITION_TOPLEFT: + if (xCenter < lcdWidth) drawLine(xCenter, yCenter-radius < 0 ? 0 : yCenter-radius, xCenter, yCenter, color); + break; + case DRAW_CORNERPOSITION_BOTTOMRIGHT: + case DRAW_CORNERPOSITION_BOTTOMLEFT: + if (xCenter < lcdWidth) drawLine(xCenter, yCenter-radius < 0 ? 0 : yCenter, xCenter, (yCenter-radius) + (2*radius), color); + break; + } + + while (x= 0) + { + y--; + ddF_y += 2; + f += ddF_y; + } + x++; + ddF_x += 2; + f += ddF_x; + + xc_px = xCenter+x; + xc_mx = xCenter-x; + xc_py = xCenter+y; + xc_my = xCenter-y; + yc_mx = yCenter-x; + yc_my = yCenter-y; + + switch (position) + { + case DRAW_CORNERPOSITION_TOPRIGHT: + if ((xc_px < lcdWidth) && (xc_px >= 0)) drawLine(xc_px, yc_my, xc_px, yCenter, color); + if ((xc_py < lcdWidth) && (xc_py >= 0)) drawLine(xc_py, yc_mx, xc_py, yCenter, color); + break; + case DRAW_CORNERPOSITION_BOTTOMRIGHT: + if ((xc_px < lcdWidth) && (xc_px >= 0)) drawLine(xc_px, yCenter, xc_px, yc_my + 2*y, color); + if ((xc_py < lcdWidth) && (xc_py >= 0)) drawLine(xc_py, yCenter, xc_py, yc_mx + 2*x, color); + break; + case DRAW_CORNERPOSITION_TOPLEFT: + if ((xc_mx < lcdWidth) && (xc_mx >= 0)) drawLine(xc_mx, yc_my, xc_mx, yCenter, color); + if ((xc_my < lcdWidth) && (xc_my >= 0)) drawLine(xc_my, yc_mx, xc_my, yCenter, color); + break; + case DRAW_CORNERPOSITION_BOTTOMLEFT: + if ((xc_mx < lcdWidth) && (xc_mx >= 0)) drawLine(xc_mx, yCenter, xc_mx, yc_my + 2*y, color); + if ((xc_my < lcdWidth) && (xc_my >= 0)) drawLine(xc_my, yCenter, xc_my, yc_mx + 2*x, color); + break; + } + } +} + /**************************************************************************/ /*! @brief Draws a simple arrow of the specified width diff --git a/drivers/lcd/tft/drawing.h b/drivers/lcd/tft/drawing.h index 7632392..d443bfd 100644 --- a/drivers/lcd/tft/drawing.h +++ b/drivers/lcd/tft/drawing.h @@ -68,6 +68,14 @@ typedef enum DRAW_ROUNDEDCORNERS_RIGHT = 5 } drawRoundedCorners_t; +typedef enum +{ + DRAW_CORNERPOSITION_TOPLEFT = 0, + DRAW_CORNERPOSITION_TOPRIGHT = 1, + DRAW_CORNERPOSITION_BOTTOMLEFT = 2, + DRAW_CORNERPOSITION_BOTTOMRIGHT = 3 +} drawCornerPosition_t; + typedef enum { DRAW_DIRECTION_LEFT, @@ -83,6 +91,7 @@ void drawLine ( uint16_t x0, uint16_t y0, uint16_t x1, uint16_t void drawLineDotted ( uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t space, uint16_t solid, uint16_t color ); void drawCircle ( uint16_t xCenter, uint16_t yCenter, uint16_t radius, uint16_t color ); void drawCircleFilled ( uint16_t xCenter, uint16_t yCenter, uint16_t radius, uint16_t color ); +void drawCornerFilled (uint16_t xCenter, uint16_t yCenter, uint16_t radius, drawCornerPosition_t position, uint16_t color); void drawArrow ( uint16_t x, uint16_t y, uint16_t size, drawDirection_t, uint16_t color ); void drawRectangle ( uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color ); void drawRectangleFilled ( uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color ); diff --git a/drivers/rtc/isl12022m/isl12022m.c b/drivers/rtc/isl12022m/isl12022m.c index b8ad0fa..ed2d0f8 100644 --- a/drivers/rtc/isl12022m/isl12022m.c +++ b/drivers/rtc/isl12022m/isl12022m.c @@ -46,7 +46,6 @@ extern volatile uint8_t I2CMasterBuffer[I2C_BUFSIZE]; extern volatile uint8_t I2CSlaveBuffer[I2C_BUFSIZE]; extern volatile uint32_t I2CReadLength, I2CWriteLength; -uint32_t i; uint8_t monthday[12]={31,28,31,30,31,30,31,31,30,31,30,31}; static bool _isl12022mInitialised = false; @@ -79,6 +78,7 @@ uint8_t isl12022mBCDToDec(uint8_t val) isl12022mError_t isl12022mWrite8 (uint8_t address, uint8_t reg, uint32_t value) { // Clear write buffers + uint32_t i; for ( i = 0; i < I2C_BUFSIZE; i++ ) { I2CMasterBuffer[i] = 0x00; @@ -104,6 +104,7 @@ isl12022mError_t isl12022mReadBuffer(uint8_t address, uint8_t reg, uint8_t *buff return ISL12022M_ERROR_I2C_BUFFEROVERFLOW; // Clear write buffers + uint32_t i; for ( i = 0; i < I2C_BUFSIZE; i++ ) { I2CMasterBuffer[i] = 0x00; diff --git a/drivers/sensors/lm75b/lm75b.c b/drivers/sensors/lm75b/lm75b.c index d5633d9..ca4d742 100644 --- a/drivers/sensors/lm75b/lm75b.c +++ b/drivers/sensors/lm75b/lm75b.c @@ -87,8 +87,6 @@ extern volatile uint8_t I2CMasterBuffer[I2C_BUFSIZE]; extern volatile uint8_t I2CSlaveBuffer[I2C_BUFSIZE]; extern volatile uint32_t I2CReadLength, I2CWriteLength; -uint32_t i; - static bool _lm75bInitialised = false; /**************************************************************************/ @@ -99,6 +97,7 @@ static bool _lm75bInitialised = false; lm75bError_e lm75bWrite8 (uint8_t reg, uint32_t value) { // Clear write buffers + uint32_t i; for ( i = 0; i < I2C_BUFSIZE; i++ ) { I2CMasterBuffer[i] = 0x00; @@ -121,6 +120,7 @@ lm75bError_e lm75bWrite8 (uint8_t reg, uint32_t value) lm75bError_e lm75bRead16(uint8_t reg, int32_t *value) { // Clear write buffers + uint32_t i; for ( i = 0; i < I2C_BUFSIZE; i++ ) { I2CMasterBuffer[i] = 0x00; diff --git a/drivers/sensors/tcs3414/tcs3414.c b/drivers/sensors/tcs3414/tcs3414.c index 2a81c71..42a5719 100644 --- a/drivers/sensors/tcs3414/tcs3414.c +++ b/drivers/sensors/tcs3414/tcs3414.c @@ -53,8 +53,6 @@ extern volatile uint8_t I2CMasterBuffer[I2C_BUFSIZE]; extern volatile uint8_t I2CSlaveBuffer[I2C_BUFSIZE]; extern volatile uint32_t I2CReadLength, I2CWriteLength; -uint32_t i; - static bool _tcs3414Initialised = false; /**************************************************************************/ @@ -65,6 +63,7 @@ static bool _tcs3414Initialised = false; tcs3414Error_e tcs3414WriteCmd (uint8_t cmd) { // Clear write buffers + uint32_t i; for ( i = 0; i < I2C_BUFSIZE; i++ ) { I2CMasterBuffer[i] = 0x00; @@ -86,6 +85,7 @@ tcs3414Error_e tcs3414WriteCmd (uint8_t cmd) tcs3414Error_e tcs3414Write8 (uint8_t reg, uint32_t value) { // Clear write buffers + uint32_t i; for ( i = 0; i < I2C_BUFSIZE; i++ ) { I2CMasterBuffer[i] = 0x00; @@ -108,6 +108,7 @@ tcs3414Error_e tcs3414Write8 (uint8_t reg, uint32_t value) tcs3414Error_e tcs3414Read16(uint8_t reg, uint16_t *value) { // Clear write buffers + uint32_t i; for ( i = 0; i < I2C_BUFSIZE; i++ ) { I2CMasterBuffer[i] = 0x00; diff --git a/drivers/sensors/tsl2561/tsl2561.c b/drivers/sensors/tsl2561/tsl2561.c index 79027b5..db82dbe 100644 --- a/drivers/sensors/tsl2561/tsl2561.c +++ b/drivers/sensors/tsl2561/tsl2561.c @@ -71,8 +71,6 @@ extern volatile uint8_t I2CMasterBuffer[I2C_BUFSIZE]; extern volatile uint8_t I2CSlaveBuffer[I2C_BUFSIZE]; extern volatile uint32_t I2CReadLength, I2CWriteLength; -uint32_t i; - static bool _tsl2561Initialised = false; static tsl2561IntegrationTime_t _tsl2561IntegrationTime = TSL2561_INTEGRATIONTIME_402MS; static tsl2561Gain_t _tsl2561Gain = TSL2561_GAIN_0X; @@ -85,6 +83,7 @@ static tsl2561Gain_t _tsl2561Gain = TSL2561_GAIN_0X; tsl2561Error_t tsl2561WriteCmd (uint8_t cmd) { // Clear write buffers + uint32_t i; for ( i = 0; i < I2C_BUFSIZE; i++ ) { I2CMasterBuffer[i] = 0x00; @@ -106,6 +105,7 @@ tsl2561Error_t tsl2561WriteCmd (uint8_t cmd) tsl2561Error_t tsl2561Write8 (uint8_t reg, uint32_t value) { // Clear write buffers + uint32_t i; for ( i = 0; i < I2C_BUFSIZE; i++ ) { I2CMasterBuffer[i] = 0x00; @@ -128,6 +128,7 @@ tsl2561Error_t tsl2561Write8 (uint8_t reg, uint32_t value) tsl2561Error_t tsl2561Read16(uint8_t reg, uint16_t *value) { // Clear write buffers + uint32_t i; for ( i = 0; i < I2C_BUFSIZE; i++ ) { I2CMasterBuffer[i] = 0x00; diff --git a/lpc134x.h b/lpc134x.h index e69af30..9da8fcb 100644 --- a/lpc134x.h +++ b/lpc134x.h @@ -2109,8 +2109,8 @@ static inline void NVIC_DisableIRQ(IRQn_t IRQn) #define USB_DEVINTST_EP6 ((unsigned int) 0x00000080) // USB core interrupt for EP6 #define USB_DEVINTST_EP7_MASK ((unsigned int) 0x00000100) #define USB_DEVINTST_EP7 ((unsigned int) 0x00000100) // USB core interrupt for EP7 -#define USB_DEVINTST_DEV_START_MASK ((unsigned int) 0x00000200) -#define USB_DEVINTST_DEV_START ((unsigned int) 0x00000200) +#define USB_DEVINTST_DEV_STAT_MASK ((unsigned int) 0x00000200) +#define USB_DEVINTST_DEV_STAT ((unsigned int) 0x00000200) #define USB_DEVINTST_CC_EMPTY_MASK ((unsigned int) 0x00000400) #define USB_DEVINTST_CC_EMPTY ((unsigned int) 0x00000400) #define USB_DEVINTST_CD_FULL_MASK ((unsigned int) 0x00000800) @@ -2140,8 +2140,8 @@ static inline void NVIC_DisableIRQ(IRQn_t IRQn) #define USB_DEVINTEN_EP6 ((unsigned int) 0x00000080) #define USB_DEVINTEN_EP7_MASK ((unsigned int) 0x00000100) #define USB_DEVINTEN_EP7 ((unsigned int) 0x00000100) -#define USB_DEVINTEN_DEV_START_MASK ((unsigned int) 0x00000200) -#define USB_DEVINTEN_DEV_START ((unsigned int) 0x00000200) +#define USB_DEVINTEN_DEV_STAT_MASK ((unsigned int) 0x00000200) +#define USB_DEVINTEN_DEV_STAT ((unsigned int) 0x00000200) #define USB_DEVINTEN_CC_EMPTY_MASK ((unsigned int) 0x00000400) #define USB_DEVINTEN_CC_EMPTY ((unsigned int) 0x00000400) #define USB_DEVINTEN_CD_FULL_MASK ((unsigned int) 0x00000800) @@ -2171,8 +2171,8 @@ static inline void NVIC_DisableIRQ(IRQn_t IRQn) #define USB_DEVINTCLR_EP6 ((unsigned int) 0x00000080) #define USB_DEVINTCLR_EP7_MASK ((unsigned int) 0x00000100) #define USB_DEVINTCLR_EP7 ((unsigned int) 0x00000100) -#define USB_DEVINTCLR_DEV_START_MASK ((unsigned int) 0x00000200) -#define USB_DEVINTCLR_DEV_START ((unsigned int) 0x00000200) +#define USB_DEVINTCLR_DEV_STAT_MASK ((unsigned int) 0x00000200) +#define USB_DEVINTCLR_DEV_STAT ((unsigned int) 0x00000200) #define USB_DEVINTCLR_CC_EMPTY_MASK ((unsigned int) 0x00000400) #define USB_DEVINTCLR_CC_EMPTY ((unsigned int) 0x00000400) #define USB_DEVINTCLR_CD_FULL_MASK ((unsigned int) 0x00000800) @@ -2202,8 +2202,8 @@ static inline void NVIC_DisableIRQ(IRQn_t IRQn) #define USB_DEVINTSET_EP6 ((unsigned int) 0x00000080) #define USB_DEVINTSET_EP7_MASK ((unsigned int) 0x00000100) #define USB_DEVINTSET_EP7 ((unsigned int) 0x00000100) -#define USB_DEVINTSET_DEV_START_MASK ((unsigned int) 0x00000200) -#define USB_DEVINTSET_DEV_START ((unsigned int) 0x00000200) +#define USB_DEVINTSET_DEV_STAT_MASK ((unsigned int) 0x00000200) +#define USB_DEVINTSET_DEV_STAT ((unsigned int) 0x00000200) #define USB_DEVINTSET_CC_EMPTY_MASK ((unsigned int) 0x00000400) #define USB_DEVINTSET_CC_EMPTY ((unsigned int) 0x00000400) #define USB_DEVINTSET_CD_FULL_MASK ((unsigned int) 0x00000800) diff --git a/main.c b/main.c index 8b75435..d0dd354 100644 --- a/main.c +++ b/main.c @@ -47,28 +47,6 @@ #include "core/cmd/cmd.h" #endif -/**************************************************************************/ -/*! - Approximates a 1 millisecond delay using "nop". This is less - accurate than a dedicated timer, but is useful in certain situations. - - The number of ticks to delay depends on the optimisation level set - when compiling (-O). Depending on the compiler settings, one of the - two defined values for 'delay' should be used. -*/ -/**************************************************************************/ -void delayms(uint32_t ms) -{ - uint32_t delay = ms * ((CFG_CPU_CCLK / 100) / 45); // Release Mode (-Os) - // uint32_t delay = ms * ((CFG_CPU_CCLK / 100) / 120); // Debug Mode (No optimisations) - - while (delay > 0) - { - __asm volatile ("nop"); - delay--; - } -} - /**************************************************************************/ /*! Main program entry point. After reset, normal code execution will diff --git a/project/cmd_tbl.h b/project/cmd_tbl.h index 7376c5a..a775021 100644 --- a/project/cmd_tbl.h +++ b/project/cmd_tbl.h @@ -63,8 +63,10 @@ void cmd_progress(uint8_t argc, char **argv); void cmd_getpixel(uint8_t argc, char **argv); void cmd_calibrate(uint8_t argc, char **argv); void cmd_orientation(uint8_t argc, char **argv); +void cmd_roundedcorner(uint8_t argc, char **argv); void cmd_text(uint8_t argc, char **argv); void cmd_textw(uint8_t argc, char **argv); +void cmd_triangle(uint8_t argc, char **argv); void cmd_tsthreshhold(uint8_t argc, char **argv); void cmd_tswait(uint8_t argc, char **argv); #ifdef CFG_SDCARD @@ -126,6 +128,7 @@ cmd_t cmd_tbl[] = { "g", 2, 2, 0, cmd_getpixel , "Get Pixel" , "'g '" }, { "l", 5, 7, 0, cmd_line , "Line" , "'l [ ]'" }, { "L", 1, 1, 0, cmd_backlight , "Backlight" , "'L <0|1>'" }, + { "n", 5, 5, 0, cmd_roundedcorner , "Rounded Corner" , "'n '" }, { "o", 0, 1, 0, cmd_orientation , "LCD Orientation" , "'o [<0|1>]'" }, { "p", 3, 3, 0, cmd_pixel , "Draw Pixel" , "'p '" }, { "P", 9, 9, 0, cmd_progress , "Progress Bar" , "'P <%> '" }, @@ -133,6 +136,7 @@ cmd_t cmd_tbl[] = { "R", 7, 7, 0, cmd_rectangleround , "Rounded Rectangle" , "'R '" }, { "s", 2, 99, 0, cmd_textw , "Text Width" , "'s '" }, { "t", 5, 99, 0, cmd_text , "Text" , "'t '" }, + { "v", 7, 8, 0, cmd_triangle , "Triangle" , "'v []'" }, { "W", 0, 1, 0, cmd_tswait , "Wait for Touch" , "'W []'" }, { "x", 0, 1, 0, cmd_tsthreshhold , "Touch Threshold" , "'x [<0..254>]'" }, #endif diff --git a/project/commands/cmd_reset.c b/project/commands/cmd_reset.c new file mode 100644 index 0000000..aa665f0 --- /dev/null +++ b/project/commands/cmd_reset.c @@ -0,0 +1,60 @@ +/**************************************************************************/ +/*! + @file cmd_reset.c + @author K. Townsend (microBuilder.eu) + + @brief Code to execute for cmd_reset in the 'core/cmd' + command-line interpretter. + + @section LICENSE + + Software License Agreement (BSD License) + + Copyright (c) 2010, microBuilder SARL + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of the copyright holders nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +/**************************************************************************/ +#include + +#include "projectconfig.h" +#include "core/cmd/cmd.h" +#include "core/cpu/cpu.h" +#include "project/commands.h" // Generic helper functions + +#ifdef CFG_I2CEEPROM + #include "drivers/eeprom/eeprom.h" + #include "core/uart/uart.h" + +/**************************************************************************/ +/*! + Resets the board using the AIRCR register +*/ +/**************************************************************************/ +void cmd_reset(uint8_t argc, char **argv) +{ + cpuReset(); +} + +#endif diff --git a/project/commands/drawing/cmd_backlight.c b/project/commands/drawing/cmd_backlight.c new file mode 100644 index 0000000..2c3c359 --- /dev/null +++ b/project/commands/drawing/cmd_backlight.c @@ -0,0 +1,65 @@ +/**************************************************************************/ +/*! + @file cmd_backlight.c + @author K. Townsend (microBuilder.eu) + + @brief Code to execute for cmd_backlight in the 'core/cmd' + command-line interpretter. + + @section LICENSE + + Software License Agreement (BSD License) + + Copyright (c) 2010, microBuilder SARL + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of the copyright holders nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +/**************************************************************************/ +#include + +#include "projectconfig.h" +#include "core/cmd/cmd.h" +#include "project/commands.h" // Generic helper functions + +#ifdef CFG_TFTLCD + #include "drivers/lcd/tft/lcd.h" + #include "drivers/lcd/tft/drawing.h" + +/**************************************************************************/ +/*! + Sets the LCD backlight state +*/ +/**************************************************************************/ +void cmd_backlight(uint8_t argc, char **argv) +{ + int32_t input; + bool state; + getNumber (argv[0], &input); + + // Set backlight + state = input < 1 ? false : true; + lcdBacklight(state); +} + +#endif diff --git a/project/commands/drawing/cmd_roundedcorner.c b/project/commands/drawing/cmd_roundedcorner.c new file mode 100644 index 0000000..fe69969 --- /dev/null +++ b/project/commands/drawing/cmd_roundedcorner.c @@ -0,0 +1,85 @@ +/**************************************************************************/ +/*! + @file cmd_roundedcorner.c + @author K. Townsend (microBuilder.eu) + + @brief Code to execute for cmd_roundedcorner in the 'core/cmd' + command-line interpretter. + + @section LICENSE + + Software License Agreement (BSD License) + + Copyright (c) 2010, microBuilder SARL + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of the copyright holders nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +/**************************************************************************/ +#include + +#include "projectconfig.h" +#include "core/cmd/cmd.h" +#include "project/commands.h" // Generic helper functions + +#ifdef CFG_TFTLCD + #include "drivers/lcd/tft/lcd.h" + #include "drivers/lcd/tft/drawing.h" + +/**************************************************************************/ +/*! + Displays a rounded corner on the LCD. +*/ +/**************************************************************************/ +void cmd_roundedcorner(uint8_t argc, char **argv) +{ + int32_t x, y, r, corner, color; + + // Convert supplied parameters + getNumber (argv[0], &x); + getNumber (argv[1], &y); + getNumber (argv[2], &r); + getNumber (argv[3], &corner); + getNumber (argv[4], &color); + + // Validate data + if (corner < 0 || corner > 3) + { + printf("Invalid Corner%s", CFG_PRINTF_NEWLINE); + return; + } + if (color < 0 || color > 0xFFFF) + { + printf("Invalid Color%s", CFG_PRINTF_NEWLINE); + return; + } + if (r < 1) + { + printf("Invalid Radius%s", CFG_PRINTF_NEWLINE); + return; + } + + drawCornerFilled (x, y, r, corner, color); +} + +#endif diff --git a/project/commands/drawing/cmd_triangle.c b/project/commands/drawing/cmd_triangle.c new file mode 100644 index 0000000..ac82dfb --- /dev/null +++ b/project/commands/drawing/cmd_triangle.c @@ -0,0 +1,85 @@ +/**************************************************************************/ +/*! + @file cmd_triangle.c + @author K. Townsend (microBuilder.eu) + + @brief Code to execute for cmd_triangle in the 'core/cmd' + command-line interpretter. + + @section LICENSE + + Software License Agreement (BSD License) + + Copyright (c) 2010, microBuilder SARL + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of the copyright holders nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +/**************************************************************************/ +#include + +#include "projectconfig.h" +#include "core/cmd/cmd.h" +#include "project/commands.h" // Generic helper functions + +#ifdef CFG_TFTLCD + #include "drivers/lcd/tft/lcd.h" + #include "drivers/lcd/tft/drawing.h" + +/**************************************************************************/ +/*! + Displays a triangle on the LCD. +*/ +/**************************************************************************/ +void cmd_triangle(uint8_t argc, char **argv) +{ + int32_t x1, y1, x2, y2, x3, y3, c, filled; + filled = 0; + + // Convert supplied parameters + getNumber (argv[0], &x1); + getNumber (argv[1], &y1); + getNumber (argv[2], &x2); + getNumber (argv[3], &y2); + getNumber (argv[4], &x3); + getNumber (argv[5], &y3); + getNumber (argv[6], &c); + if (argc == 8) + { + getNumber (argv[7], &filled); + } + + // ToDo: Validate data! + if (c < 0 || c > 0xFFFF) + { + printf("Invalid Color%s", CFG_PRINTF_NEWLINE); + return; + } + + if (filled) + drawTriangleFilled(x1, y1, x2, y2, x3, y3, (uint16_t)c); + else + drawTriangle(x1, y1, x2, y2, x3, y3, (uint16_t)c); +} + +#endif diff --git a/projectconfig.h b/projectconfig.h index c90a88a..1252ef0 100644 --- a/projectconfig.h +++ b/projectconfig.h @@ -48,8 +48,8 @@ are using by enabling one of the following definitions. The code base will then try to configure itself accordingly for that board. -----------------------------------------------------------------------*/ - // #define CFG_BRD_LPC1343_REFDESIGN - #define CFG_BRD_LPC1343_TFTLCDSTANDALONE_USB + #define CFG_BRD_LPC1343_REFDESIGN + // #define CFG_BRD_LPC1343_TFTLCDSTANDALONE_USB // #define CFG_BRD_LPC1343_TFTLCDSTANDALONE_UART // #define CFG_BRD_LPC1343_802154USBSTICK /*=========================================================================*/ @@ -159,6 +159,25 @@ /*=========================================================================*/ +/*========================================================================= + ALTERNATE RESET PIN + ----------------------------------------------------------------------- + + CFG_ALTRESET If defined, indicates that a GPIO pin should be + configured as an alternate reset pin in addition + to the dedicated reset pin. + CFG_ALTRESET_PORT The GPIO port where the alt reset pin is located + CFG_ALTRESET_PIN The GPIO pin where the alt reset pin is located + + -----------------------------------------------------------------------*/ + #ifdef CFG_BRD_LPC1343_TFTLCDSTANDALONE_UART + #define CFG_ALTRESET + #define CFG_ALTRESET_PORT (1) + #define CFG_ALTRESET_PIN (5) // P1.5 = RTS + #endif +/*=========================================================================*/ + + /*========================================================================= UART ----------------------------------------------------------------------- @@ -462,7 +481,7 @@ #ifdef CFG_BRD_LPC1343_TFTLCDSTANDALONE_USB #define CFG_INTERFACE #define CFG_INTERFACE_MAXMSGSIZE (256) - #define CFG_INTERFACE_PROMPT "LCD >> " + #define CFG_INTERFACE_PROMPT "CMD >> " #define CFG_INTERFACE_SILENTMODE (0) #define CFG_INTERFACE_DROPCR (0) #define CFG_INTERFACE_ENABLEIRQ (0) @@ -479,7 +498,7 @@ #ifdef CFG_BRD_LPC1343_TFTLCDSTANDALONE_UART #define CFG_INTERFACE #define CFG_INTERFACE_MAXMSGSIZE (256) - #define CFG_INTERFACE_PROMPT "LCD >> " + #define CFG_INTERFACE_PROMPT ">>" #define CFG_INTERFACE_SILENTMODE (1) #define CFG_INTERFACE_DROPCR (1) #define CFG_INTERFACE_ENABLEIRQ (1) diff --git a/sysdefs.h b/sysdefs.h index bf79c8e..9b786b4 100644 --- a/sysdefs.h +++ b/sysdefs.h @@ -45,8 +45,13 @@ // Stay compatible with ugly "windows" style #define BOOL bool + +#ifndef TRUE #define TRUE true +#endif +#ifndef FALSE #define FALSE false +#endif typedef volatile uint8_t REG8; typedef volatile uint16_t REG16; diff --git a/sysinit.c b/sysinit.c index 60b4d3b..80d2f5c 100644 --- a/sysinit.c +++ b/sysinit.c @@ -130,6 +130,13 @@ void systemInit() gpioSetDir(CFG_LED_PORT, CFG_LED_PIN, 1); gpioSetValue(CFG_LED_PORT, CFG_LED_PIN, CFG_LED_OFF); + // Config alt reset pin if requested (really only relevant to LPC1343 LCD Board) + #ifdef CFG_ALTRESET + gpioSetDir (CFG_ALTRESET_PORT, CFG_ALTRESET_PIN, gpioDirection_Input); + gpioSetInterrupt (CFG_ALTRESET_PORT, CFG_ALTRESET_PIN, gpioInterruptSense_Level, gpioInterruptEdge_Single, gpioInterruptEvent_ActiveHigh); + gpioIntEnable (CFG_ALTRESET_PORT, CFG_ALTRESET_PIN); + #endif + // Initialise EEPROM #ifdef CFG_I2CEEPROM mcp24aaInit(); diff --git a/tools/testfirmware/usbcli.bin b/tools/testfirmware/usbcli.bin deleted file mode 100644 index 652047ca4b51b65a9539ffe72e00bdf1c80e4248..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 13026 zcmd6O4Rlk-weHM0N52-fWSbz%4jf5#EF(J+wxJFX5HcLw62v5s21saSu!Fp6u&_-k z-=;;7wAW43n-J%|%TJn1lf1h^^K-FNzm_&Exy@}~Xp=4pk}h~O&xfQfDcsv08-owF zvEDaFHa}@zU*B83Ydx8*GqY#Uo;`c^-ZQh0@EC~o9*&Skzd1R z1E3pl1mJD>w&ZOnuQxk{2%C*v5wHzhlB1*A_GdYNh3kyCPo?Ab+p(mhAauLDDfB%^}{;jd|MEr*I z?-CJ-(-nNCZt8qbz>vJ(p-b{H>dT7K1$6P%RJ5)qz$LjT^^Kp8)_Jg|GZ3yMBu`u@BRpH<90%u@E@ySl^v?_N z(|j5Kn>m|69~g~qVPoOh;RsXLOPA$NN7z`UVJaQrXkE=-!7s)IzaL-(L;+-gC?%>b zs1x%d?$NJpbu07uyfAk;Uip7hPmgt{$#D`VYc)v}KO{GX8kKm*rtpiG3CF(U+BeDF z1W8CD&c;4RWZrX!rV-AVoloam64sD4bX&?QvvPJQJ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