From: Kevin Townsend Date: Wed, 13 Jul 2011 00:33:01 +0000 (+0200) Subject: Added backlight, reset, triangle and corner commands X-Git-Url: https://git.rohieb.name/hackover2013-badge-firmware.git/commitdiff_plain/d537298fdd7d39e4cb0e74e8e6d227245d638afe?ds=inline Added backlight, reset, triangle and corner commands --- 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 dfffc1d..0006aac 100644 Binary files a/build/codelite/LPC1343 Workspace.tags and b/build/codelite/LPC1343 Workspace.tags differ 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 652047c..0000000 Binary files a/tools/testfirmware/usbcli.bin and /dev/null differ