From 3fc39b51a49bdabb11e47d8032d4a2d3eed2a96f Mon Sep 17 00:00:00 2001 From: Stephen Paulger Date: Thu, 10 Oct 2013 11:31:09 +0100 Subject: [PATCH 1/9] Build after project rename --- workspace_tools/export/ds5_5_lpc1768.cproject.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workspace_tools/export/ds5_5_lpc1768.cproject.tmpl b/workspace_tools/export/ds5_5_lpc1768.cproject.tmpl index 1157fcd167..1cf286f4d8 100644 --- a/workspace_tools/export/ds5_5_lpc1768.cproject.tmpl +++ b/workspace_tools/export/ds5_5_lpc1768.cproject.tmpl @@ -13,7 +13,7 @@ - + From f51de7be24362deb32d473da81a39591d7801509 Mon Sep 17 00:00:00 2001 From: Stephen Paulger Date: Thu, 10 Oct 2013 11:31:42 +0100 Subject: [PATCH 2/9] Add symbols --- workspace_tools/export/ds5_5_lpc1768.cproject.tmpl | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/workspace_tools/export/ds5_5_lpc1768.cproject.tmpl b/workspace_tools/export/ds5_5_lpc1768.cproject.tmpl index 1cf286f4d8..5a5fff4d49 100644 --- a/workspace_tools/export/ds5_5_lpc1768.cproject.tmpl +++ b/workspace_tools/export/ds5_5_lpc1768.cproject.tmpl @@ -26,6 +26,11 @@ {% endfor %} @@ -69,6 +74,11 @@ + From f7425b4e7253be2c54657e4831acb268315f23c9 Mon Sep 17 00:00:00 2001 From: Stephen Paulger Date: Thu, 10 Oct 2013 11:32:29 +0100 Subject: [PATCH 3/9] Base project name on mbed project name --- workspace_tools/export/ds5_5_lpc1768.project.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workspace_tools/export/ds5_5_lpc1768.project.tmpl b/workspace_tools/export/ds5_5_lpc1768.project.tmpl index b5f6fcfc9f..4f892f370b 100644 --- a/workspace_tools/export/ds5_5_lpc1768.project.tmpl +++ b/workspace_tools/export/ds5_5_lpc1768.project.tmpl @@ -1,6 +1,6 @@ - ds5_lpc1768 + {{name}}_ds5_lpc1768 From a34c747a21b454668c57c33ee8e9257269318512 Mon Sep 17 00:00:00 2001 From: Stephen Paulger Date: Thu, 10 Oct 2013 11:38:02 +0100 Subject: [PATCH 4/9] Base DS-5 lpc11u24 project name on mbed project name --- workspace_tools/export/ds5_5_lpc11u24.project.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workspace_tools/export/ds5_5_lpc11u24.project.tmpl b/workspace_tools/export/ds5_5_lpc11u24.project.tmpl index fedc73660a..8ad8f0a24d 100644 --- a/workspace_tools/export/ds5_5_lpc11u24.project.tmpl +++ b/workspace_tools/export/ds5_5_lpc11u24.project.tmpl @@ -1,6 +1,6 @@ - ds5_lpc11u24 + {{name}}_ds5_lpc11u24 From d9ed7aba77d34e9ae9ed28783032e37a65bceeaf Mon Sep 17 00:00:00 2001 From: 0xc0170 Date: Thu, 17 Oct 2013 19:32:40 +0200 Subject: [PATCH 5/9] CMSIS KL46 files (were KL25 renamed) --- .../TARGET_Freescale/TARGET_KL46Z/MKL46Z4.h | 2107 +++++++++++++++-- .../TARGET_KL46Z/system_MKL46Z4.c | 46 +- .../TARGET_KL46Z/system_MKL46Z4.h | 24 +- .../TARGET_Freescale/TARGET_KL46Z/objects.h | 2 +- .../TARGET_KL46Z/serial_api.c | 6 +- .../TARGET_Freescale/TARGET_KL46Z/spi_api.c | 56 +- 6 files changed, 1964 insertions(+), 277 deletions(-) diff --git a/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_KL46Z/MKL46Z4.h b/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_KL46Z/MKL46Z4.h index 560a973b7c..60588932d3 100644 --- a/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_KL46Z/MKL46Z4.h +++ b/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_KL46Z/MKL46Z4.h @@ -1,35 +1,41 @@ /* ** ################################################################### -** Processor: MKL46Z128VLK4 +** Processors: MKL46Z256VLH4 +** MKL46Z128VLH4 +** MKL46Z256VLL4 +** MKL46Z128VLL4 +** MKL46Z256VMC4 +** MKL46Z128VMC4 +** ** Compilers: ARM Compiler ** Freescale C/C++ for Embedded ARM ** GNU C Compiler ** IAR ANSI C/C++ Compiler for ARM ** -** Reference manual: KL25RM, Rev.1, Jun 2012 -** Version: rev. 1.1, 2012-06-21 +** Reference manual: KL46P121M48SF4RM, Rev.1 Draft A, Aug 2012 +** Version: rev. 2.0, 2012-12-12 ** ** Abstract: ** CMSIS Peripheral Access Layer for MKL46Z4 ** -** Copyright: 1997 - 2012 Freescale Semiconductor, Inc. All Rights Reserved. +** Copyright: 1997 - 2012 Freescale, Inc. All Rights Reserved. ** ** http: www.freescale.com ** mail: support@freescale.com ** ** Revisions: -** - rev. 1.0 (2012-06-13) +** - rev. 1.0 (2012-10-16) ** Initial version. -** - rev. 1.1 (2012-06-21) -** Update according to reference manual rev. 1. +** - rev. 2.0 (2012-12-12) +** Update to reference manual rev. 1. ** ** ################################################################### */ /** * @file MKL46Z4.h - * @version 1.1 - * @date 2012-06-21 + * @version 2.0 + * @date 2012-12-12 * @brief CMSIS Peripheral Access Layer for MKL46Z4 * * CMSIS Peripheral Access Layer for MKL46Z4 @@ -40,9 +46,9 @@ /** Memory map major version (memory maps with equal major version number are * compatible) */ -#define MCU_MEM_MAP_VERSION 0x0100u +#define MCU_MEM_MAP_VERSION 0x0200u /** Memory map minor version */ -#define MCU_MEM_MAP_VERSION_MINOR 0x0001u +#define MCU_MEM_MAP_VERSION_MINOR 0x0000u /* ---------------------------------------------------------------------------- @@ -64,12 +70,12 @@ typedef enum IRQn { SysTick_IRQn = -1, /**< Cortex-M0 System Tick Interrupt */ /* Device specific interrupts */ - DMA0_IRQn = 0, /**< DMA channel 0 transfer complete interrupt */ - DMA1_IRQn = 1, /**< DMA channel 1 transfer complete interrupt */ - DMA2_IRQn = 2, /**< DMA channel 2 transfer complete interrupt */ - DMA3_IRQn = 3, /**< DMA channel 3 transfer complete interrupt */ + DMA0_IRQn = 0, /**< DMA channel 0 transfer complete/error interrupt */ + DMA1_IRQn = 1, /**< DMA channel 1 transfer complete/error interrupt */ + DMA2_IRQn = 2, /**< DMA channel 2 transfer complete/error interrupt */ + DMA3_IRQn = 3, /**< DMA channel 3 transfer complete/error interrupt */ Reserved20_IRQn = 4, /**< Reserved interrupt 20 */ - FTFA_IRQn = 5, /**< FTFA interrupt */ + FTFA_IRQn = 5, /**< FTFA command complete/read collision interrupt */ LVD_LVW_IRQn = 6, /**< Low Voltage Detect, Low Voltage Warning */ LLW_IRQn = 7, /**< Low Leakage Wakeup */ I2C0_IRQn = 8, /**< I2C0 interrupt */ @@ -87,13 +93,13 @@ typedef enum IRQn { RTC_IRQn = 20, /**< RTC interrupt */ RTC_Seconds_IRQn = 21, /**< RTC seconds interrupt */ PIT_IRQn = 22, /**< PIT timer interrupt */ - Reserved39_IRQn = 23, /**< Reserved interrupt 39 */ + I2S0_IRQn = 23, /**< I2S0 transmit interrupt */ USB0_IRQn = 24, /**< USB0 interrupt */ - DAC0_IRQn = 25, /**< DAC interrupt */ + DAC0_IRQn = 25, /**< DAC0 interrupt */ TSI0_IRQn = 26, /**< TSI0 interrupt */ MCG_IRQn = 27, /**< MCG interrupt */ LPTimer_IRQn = 28, /**< LPTimer interrupt */ - Reserved45_IRQn = 29, /**< Reserved interrupt 45 */ + LCD_IRQn = 29, /**< Segment LCD Interrupt */ PORTA_IRQn = 30, /**< Port A interrupt */ PORTD_IRQn = 31 /**< Port D interrupt */ } IRQn_Type; @@ -447,8 +453,8 @@ typedef struct { #define CMP_MUXCR_PSEL_MASK 0x38u #define CMP_MUXCR_PSEL_SHIFT 3 #define CMP_MUXCR_PSEL(x) (((uint8_t)(((uint8_t)(x))<C1: CLKS=0,FRDIV=0,IREFS=1,IRCLKEN=1,IREFSTEN=0 */ MCG->C1 = (uint8_t)0x06U; - /* MCG_C2: LOCRE0=0,??=0,RANGE0=0,HGO0=0,EREFS0=0,LP=0,IRCS=0 */ - MCG->C2 = (uint8_t)0x00U; + /* MCG_C2: LOCRE0=0,RANGE0=0,HGO0=0,EREFS0=0,LP=0,IRCS=0 */ + MCG->C2 &= (uint8_t)~(uint8_t)0xBFU; /* MCG->C4: DMX32=0,DRST_DRS=1 */ MCG->C4 = (uint8_t)((MCG->C4 & (uint8_t)~(uint8_t)0xC0U) | (uint8_t)0x20U); /* OSC0->CR: ERCLKEN=1,??=0,EREFSTEN=0,??=0,SC2P=0,SC4P=0,SC8P=0,SC16P=0 */ @@ -124,11 +130,11 @@ void SystemInit (void) { /* PORTA->PCR19: ISF=0,MUX=0 */ PORTA->PCR[19] &= (uint32_t)~0x01000700UL; /* Switch to FBE Mode */ - /* OSC0->CR: ERCLKEN=1,??=0,EREFSTEN=0,??=0,SC2P=1,SC4P=0,SC8P=0,SC16P=1 */ - OSC0->CR = (uint8_t)0x89U; - /* MCG->C2: LOCRE0=0,??=0,RANGE0=2,HGO0=0,EREFS0=1,LP=0,IRCS=0 */ - MCG->C2 = (uint8_t)0x24U; - /* MCG->C1: CLKS=2,FRDIV=3,IREFS=0,IRCLKEN=1,IREFSTEN=0 */ + /* MCG_C2: LOCRE0=0,RANGE0=2,HGO0=0,EREFS0=1,LP=0,IRCS=0 */ + MCG->C2 = (uint8_t)((MCG->C2 & (uint8_t)~(uint8_t)0x9BU) | (uint8_t)0x24U); + /* OSC0->CR: ERCLKEN=1,??=0,EREFSTEN=0,??=0,SC2P=1,SC4P=0,SC8P=0,SC16P=0 */ + OSC0->CR = (uint8_t)0x80U; + /* MCG_C1: CLKS=2,FRDIV=3,IREFS=0,IRCLKEN=1,IREFSTEN=0 */ MCG->C1 = (uint8_t)0x9AU; /* MCG->C4: DMX32=0,DRST_DRS=0 */ MCG->C4 &= (uint8_t)~(uint8_t)0xE0U; @@ -162,10 +168,10 @@ void SystemInit (void) { /* PORTA->PCR19: ISF=0,MUX=0 */ PORTA->PCR[19] &= (uint32_t)~0x01000700UL; /* Switch to FBE Mode */ - /* OSC0->CR: ERCLKEN=1,??=0,EREFSTEN=0,??=0,SC2P=1,SC4P=0,SC8P=0,SC16P=1 */ - OSC0->CR = (uint8_t)0x89U; /* MCG->C2: LOCRE0=0,??=0,RANGE0=2,HGO0=0,EREFS0=1,LP=0,IRCS=0 */ MCG->C2 = (uint8_t)0x24U; + /* OSC0->CR: ERCLKEN=1,??=0,EREFSTEN=0,??=0,SC2P=1,SC4P=0,SC8P=0,SC16P=0 */ + OSC0->CR = (uint8_t)0x80U; /* MCG->C1: CLKS=2,FRDIV=3,IREFS=0,IRCLKEN=1,IREFSTEN=0 */ MCG->C1 = (uint8_t)0x9AU; /* MCG->C4: DMX32=0,DRST_DRS=0 */ @@ -179,8 +185,8 @@ void SystemInit (void) { while((MCG->S & 0x0CU) != 0x08U) { /* Wait until external reference clock is selected as MCG output */ } /* Switch to BLPE Mode */ - /* MCG->C2: LOCRE0=0,??=0,RANGE0=2,HGO0=0,EREFS0=1,LP=1,IRCS=0 */ - MCG->C2 = (uint8_t)0x26U; + /* MCG_C2: LOCRE0=0,RANGE0=2,HGO0=0,EREFS0=1,LP=1,IRCS=0 */ + MCG->C2 = (uint8_t)((MCG->C2 & (uint8_t)~(uint8_t)0x99U) | (uint8_t)0x26U); while((MCG->S & 0x0CU) != 0x08U) { /* Wait until external reference clock is selected as MCG output */ } #endif /* (CLOCK_SETUP == 2) */ diff --git a/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_KL46Z/system_MKL46Z4.h b/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_KL46Z/system_MKL46Z4.h index 1f4d8ab644..e88304711a 100644 --- a/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_KL46Z/system_MKL46Z4.h +++ b/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_KL46Z/system_MKL46Z4.h @@ -1,37 +1,43 @@ /* ** ################################################################### -** Processor: MKL46Z128VLK4 +** Processors: MKL46Z256VLH4 +** MKL46Z128VLH4 +** MKL46Z256VLL4 +** MKL46Z128VLL4 +** MKL46Z256VMC4 +** MKL46Z128VMC4 +** ** Compilers: ARM Compiler ** Freescale C/C++ for Embedded ARM ** GNU C Compiler ** IAR ANSI C/C++ Compiler for ARM ** -** Reference manual: KL25RM, Rev.1, Jun 2012 -** Version: rev. 1.1, 2012-06-21 +** Reference manual: KL46P121M48SF4RM, Rev.1 Draft A, Aug 2012 +** Version: rev. 2.0, 2012-12-12 ** ** Abstract: ** Provides a system configuration function and a global variable that ** contains the system frequency. It configures the device and initializes ** the oscillator (PLL) that is part of the microcontroller device. ** -** Copyright: 2012 Freescale Semiconductor, Inc. All Rights Reserved. +** Copyright: 2012 Freescale, Inc. All Rights Reserved. ** ** http: www.freescale.com ** mail: support@freescale.com ** ** Revisions: -** - rev. 1.0 (2012-06-13) +** - rev. 1.0 (2012-10-16) ** Initial version. -** - rev. 1.1 (2012-06-21) -** Update according to reference manual rev. 1. +** - rev. 2.0 (2012-12-12) +** Update to reference manual rev. 1. ** ** ################################################################### */ /** * @file MKL46Z4 - * @version 1.1 - * @date 2012-06-21 + * @version 2.0 + * @date 2012-12-12 * @brief Device specific configuration file for MKL46Z4 (header file) * * Provides a system configuration function and a global variable that contains diff --git a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KL46Z/objects.h b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KL46Z/objects.h index a5366deaed..8178967acb 100644 --- a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KL46Z/objects.h +++ b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KL46Z/objects.h @@ -46,7 +46,7 @@ struct pwmout_s { }; struct serial_s { - UARTLP_Type *uart; + UART0_Type *uart; int index; }; diff --git a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KL46Z/serial_api.c b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KL46Z/serial_api.c index 3414e47ee3..f978799de2 100644 --- a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KL46Z/serial_api.c +++ b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KL46Z/serial_api.c @@ -71,7 +71,7 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) { error("Serial pinout mapping failed"); } - obj->uart = (UARTLP_Type *)uart; + obj->uart = (UART0_Type *)uart; // enable clk switch (uart) { case UART_0: SIM->SOPT2 |= SIM_SOPT2_PLLFLLSEL_MASK | (1<index == 0) { - obj->uart->C4 &= ~UARTLP_C4_M10_MASK; - obj->uart->C4 |= (m10 << UARTLP_C4_M10_SHIFT); + obj->uart->C4 &= ~UART0_C4_M10_MASK; + obj->uart->C4 |= (m10 << UART0_C4_M10_SHIFT); } // stop bits diff --git a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KL46Z/spi_api.c b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KL46Z/spi_api.c index e76c5aa137..c717768b0d 100644 --- a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KL46Z/spi_api.c +++ b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KL46Z/spi_api.c @@ -96,7 +96,7 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel // enable power and clocking switch ((int)obj->spi) { - case SPI_0: SIM->SCGC5 |= 1 << 11; SIM->SCGC4 |= 1 << 22; break; + case SPI_0: SIM->SCGC5 |= 1 << 13; SIM->SCGC4 |= 1 << 22; break; case SPI_1: SIM->SCGC5 |= 1 << 13; SIM->SCGC4 |= 1 << 23; break; } @@ -110,6 +110,7 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel // enable SPI obj->spi->C1 |= SPI_C1_SPE_MASK; + obj->spi->C2 &= ~SPI_C2_SPIMODE_MASK; //8bit // pin out the spi pins pinmap_pinout(mosi, PinMap_SPI_MOSI); @@ -124,8 +125,8 @@ void spi_free(spi_t *obj) { // [TODO] } void spi_format(spi_t *obj, int bits, int mode, int slave) { - if (bits != 8) { - error("Only 8bits SPI supported"); + if ((bits != 8) && (bits != 16)) { + error("Only 8/16 bits SPI supported"); } if ((mode < 0) || (mode > 3)) { @@ -141,6 +142,11 @@ void spi_format(spi_t *obj, int bits, int mode, int slave) { // write new value obj->spi->C1 |= c1_data; + if (bits == 8) { + obj->spi->C2 &= ~SPI_C2_SPIMODE_MASK; + } else { + obj->spi->C2 |= SPI_C2_SPIMODE_MASK; + } } void spi_frequency(spi_t *obj, int hz) { @@ -184,13 +190,28 @@ static inline int spi_readable(spi_t * obj) { } int spi_master_write(spi_t *obj, int value) { - // wait tx buffer empty - while(!spi_writeable(obj)); - obj->spi->D = (value & 0xff); + int ret; + if (obj->spi->C2 & SPI_C2_SPIMODE_MASK) { + // 16bit + while(!spi_writeable(obj)); + obj->spi->DL = (value & 0xff); + obj->spi->DH = ((value >> 8) & 0xff); - // wait rx buffer full - while (!spi_readable(obj)); - return obj->spi->D & 0xff; + // wait rx buffer full + while (!spi_readable(obj)); + ret = obj->spi->DH; + ret = (ret << 8) | obj->spi->DL; + } else { + //8bit + while(!spi_writeable(obj)); + obj->spi->DL = (value & 0xff); + + // wait rx buffer full + while (!spi_readable(obj)); + ret = (obj->spi->DL & 0xff); + } + + return ret; } int spi_slave_receive(spi_t *obj) { @@ -198,10 +219,23 @@ int spi_slave_receive(spi_t *obj) { } int spi_slave_read(spi_t *obj) { - return obj->spi->D; + int ret; + if (obj->spi->C2 & SPI_C2_SPIMODE_MASK) { + ret = obj->spi->DH; + ret = ((ret << 8) | obj->spi->DL); + } else { + ret = obj->spi->DL; + } + return ret; } void spi_slave_write(spi_t *obj, int value) { while (!spi_writeable(obj)); - obj->spi->D = value; + if (obj->spi->C2 & SPI_C2_SPIMODE_MASK) { + obj->spi->DL = (value & 0xff); + obj->spi->DH = ((value >> 8) & 0xff); + } else { + obj->spi->DL = value; + } + } From 43eeaa338f07ad1d861a33c2f6f6e36d16abda10 Mon Sep 17 00:00:00 2001 From: Stephen Paulger Date: Tue, 29 Oct 2013 10:35:15 +0000 Subject: [PATCH 6/9] Fix DS5 11U24 exporter --- workspace_tools/export/ds5_5_lpc11u24.cproject.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workspace_tools/export/ds5_5_lpc11u24.cproject.tmpl b/workspace_tools/export/ds5_5_lpc11u24.cproject.tmpl index 17714e3789..32adc51b8d 100644 --- a/workspace_tools/export/ds5_5_lpc11u24.cproject.tmpl +++ b/workspace_tools/export/ds5_5_lpc11u24.cproject.tmpl @@ -13,7 +13,7 @@ - + From d3ca81890523e865d0264f40a469770a07671a5d Mon Sep 17 00:00:00 2001 From: Yihui Xiong Date: Fri, 1 Nov 2013 12:38:27 +0800 Subject: [PATCH 7/9] add readable(), writeable() and settings changed callback to USBSerial --- libraries/USBDevice/USBSerial/USBCDC.cpp | 26 +++++++++++++++ libraries/USBDevice/USBSerial/USBCDC.h | 12 +++++++ libraries/USBDevice/USBSerial/USBSerial.h | 40 ++++++++++++++++++++--- 3 files changed, 74 insertions(+), 4 deletions(-) diff --git a/libraries/USBDevice/USBSerial/USBCDC.cpp b/libraries/USBDevice/USBSerial/USBCDC.cpp index 29ea68a62e..5dff9f1a4f 100644 --- a/libraries/USBDevice/USBSerial/USBCDC.cpp +++ b/libraries/USBDevice/USBSerial/USBCDC.cpp @@ -52,6 +52,7 @@ bool USBCDC::USBCallback_request(void) { break; case CDC_SET_LINE_CODING: transfer->remaining = 7; + transfer->notify = true; success = true; terminal_connected = true; break; @@ -67,6 +68,31 @@ bool USBCDC::USBCallback_request(void) { return success; } +void USBCDC::USBCallback_requestCompleted(uint8_t *buf, uint32_t length) { + // Request of setting line coding has 7 bytes + if (length != 7) { + return; + } + + CONTROL_TRANSFER * transfer = getTransferPtr(); + + /* Process class-specific requests */ + if (transfer->setup.bmRequestType.Type == CLASS_TYPE) { + if (transfer->setup.bRequest == CDC_SET_LINE_CODING) { + if (memcmp(cdc_line_coding, buf, 7)) { + memcpy(cdc_line_coding, buf, 7); + + int baud = buf[0] + (buf[1] << 8) + + (buf[2] << 16) + (buf[3] << 24); + int stop = buf[4]; + int bits = buf[6]; + int parity = buf[5]; + + lineCodingChanged(baud, bits, parity, stop); + } + } + } +} // Called in ISR context // Set configuration. Return false if the diff --git a/libraries/USBDevice/USBSerial/USBCDC.h b/libraries/USBDevice/USBSerial/USBCDC.h index 9d810f8ff8..c2f14e5b1e 100644 --- a/libraries/USBDevice/USBSerial/USBCDC.h +++ b/libraries/USBDevice/USBSerial/USBCDC.h @@ -99,9 +99,21 @@ protected: * @returns true if successful */ bool readEP_NB(uint8_t * buffer, uint32_t * size); + + /* + * Called by USBCallback_requestCompleted when CDC line coding is changed + * Warning: Called in ISR + * + * @param baud The baud rate + * @param bits The number of bits in a word (5-8) + * @param parity The parity + * @param stop The number of stop bits (1 or 2) + */ + virtual void lineCodingChanged(int baud, int bits, int parity, int stop) {}; protected: virtual bool USBCallback_request(); + virtual void USBCallback_requestCompleted(uint8_t *buf, uint32_t length); virtual bool USBCallback_setConfiguration(uint8_t configuration); volatile bool terminal_connected; diff --git a/libraries/USBDevice/USBSerial/USBSerial.h b/libraries/USBDevice/USBSerial/USBSerial.h index 49fab116f8..7a73c8a93b 100644 --- a/libraries/USBDevice/USBSerial/USBSerial.h +++ b/libraries/USBDevice/USBSerial/USBSerial.h @@ -55,7 +55,9 @@ public: * @param product_release Your preoduct_release (default: 0x0001) * */ - USBSerial(uint16_t vendor_id = 0x1f00, uint16_t product_id = 0x2012, uint16_t product_release = 0x0001): USBCDC(vendor_id, product_id, product_release), buf(128){ }; + USBSerial(uint16_t vendor_id = 0x1f00, uint16_t product_id = 0x2012, uint16_t product_release = 0x0001): USBCDC(vendor_id, product_id, product_release), buf(128){ + settingsChangedCallback = 0; + }; /** @@ -79,6 +81,22 @@ public: * @returns the number of bytes available */ uint8_t available(); + + /** Determine if there is a character available to read + * + * @returns + * 1 if there is a character available to read, + * 0 otherwise + */ + int readable() { return available() ? 1 : 0; } + + /** Determine if there is space available to write a character + * + * @returns + * 1 if there is space to write a character, + * 0 otherwise + */ + int writeable() { return 1; } // always return 1, for write operation is blocking /** * Write a block of data. @@ -110,19 +128,33 @@ public: * * @param fptr function pointer */ - void attach(void (*fn)(void)) { - if(fn != NULL) { - rx.attach(fn); + void attach(void (*fptr)(void)) { + if(fptr != NULL) { + rx.attach(fptr); } } + /** + * Attach a callback to call when serial's settings are changed. + * + * @param fptr function pointer + */ + void attach(void (*fptr)(int baud, int bits, int parity, int stop)) { + settingsChangedCallback = fptr; + } protected: virtual bool EP2_OUT_callback(); + virtual void lineCodingChanged(int baud, int bits, int parity, int stop){ + if (settingsChangedCallback) { + settingsChangedCallback(baud, bits, parity, stop); + } + } private: FunctionPointer rx; CircBuffer buf; + void (*settingsChangedCallback)(int baud, int bits, int parity, int stop); }; #endif From e0d0dddc784a8fa12c8161ca666c5fc5d111371f Mon Sep 17 00:00:00 2001 From: Emilio Monti Date: Tue, 5 Nov 2013 14:58:47 +0000 Subject: [PATCH 8/9] Additional toolchains to the official builds for the KL25Z and LPC4088 --- workspace_tools/build_release.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/workspace_tools/build_release.py b/workspace_tools/build_release.py index be64859a6c..1c3adeb742 100644 --- a/workspace_tools/build_release.py +++ b/workspace_tools/build_release.py @@ -27,13 +27,13 @@ from workspace_tools.targets import TARGET_MAP OFFICIAL_MBED_LIBRARY_BUILD = ( - ('KL25Z', ('ARM',)), + ('KL25Z', ('ARM', 'GCC_ARM')), ('LPC11U24', ('ARM', 'uARM')), ('LPC1768', ('ARM', 'GCC_ARM', 'GCC_CR', 'GCC_CS', 'IAR')), ('LPC2368', ('ARM',)), ('LPC812', ('uARM',)), ('LPC1347', ('ARM',)), - ('LPC4088', ('ARM',)), + ('LPC4088', ('ARM', 'GCC_ARM', 'GCC_CR')), ('LPC1114', ('uARM',)), ) From 250610e13cd373e3e263dd0cb78f0749c73f6a5b Mon Sep 17 00:00:00 2001 From: Stephen Paulger Date: Tue, 5 Nov 2013 23:39:49 +0000 Subject: [PATCH 9/9] Add expoter README Includes table of exporter supported toolchains by platform. --- workspace_tools/export/README.md | 77 ++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 workspace_tools/export/README.md diff --git a/workspace_tools/export/README.md b/workspace_tools/export/README.md new file mode 100644 index 0000000000..822e2482ea --- /dev/null +++ b/workspace_tools/export/README.md @@ -0,0 +1,77 @@ +Exporter Toolchain/Platform Support +----------------------------------- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Code RedCode SourceryDS-5GCC ARMIARKEIL uVision
NXP LPC1768
NXP LPC11U24
NXP LPC812
NXP LPC4088
NXP LPC1347
NXP LPC1114
Freescale KL25Z