From 8d7c3da179ec9a1ba2de1244ed8b072dff7e7390 Mon Sep 17 00:00:00 2001 From: 0xc0170 Date: Mon, 30 Dec 2013 11:39:36 +0100 Subject: [PATCH 01/24] i2c clock from global clock value, syntax corrections --- .../hal/TARGET_Freescale/TARGET_K20D5M/i2c_api.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/i2c_api.c b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/i2c_api.c index 5762b5d142..2529761629 100644 --- a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/i2c_api.c +++ b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/i2c_api.c @@ -165,10 +165,11 @@ static int i2c_do_write(i2c_t *obj, int value) { } static int i2c_do_read(i2c_t *obj, char * data, int last) { - if (last) + if (last) { i2c_send_nack(obj); - else + } else { i2c_send_ack(obj); + } *data = (obj->i2c->D & 0xFF); @@ -184,7 +185,7 @@ void i2c_frequency(i2c_t *obj, int hz) { uint32_t ref = 0; uint8_t i, j; // bus clk - uint32_t PCLK = 24000000u; + uint32_t PCLK = SystemCoreClock/2; uint32_t pulse = PCLK / (hz * 2); // we look for the values that minimize the error @@ -237,9 +238,8 @@ int i2c_read(i2c_t *obj, int address, char *data, int length, int stop) { } // If not repeated start, send stop. - if (stop) { + if (stop) i2c_stop(obj); - } // last read data[count-1] = obj->i2c->D; @@ -326,11 +326,9 @@ int i2c_slave_receive(i2c_t *obj) { // read addressed case 0xE6: return 1; - // write addressed case 0xE2: return 3; - default: return 0; } From a384d1d875ac4b5d9a5cb4d2c8f695c66039fa3c Mon Sep 17 00:00:00 2001 From: 0xc0170 Date: Mon, 30 Dec 2013 18:12:01 +0100 Subject: [PATCH 02/24] pwm channel 7 correction, enhanced mode --- .../TARGET_K20D5M/pwmout_api.c | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/pwmout_api.c b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/pwmout_api.c index 5936ee03b8..6c362e0e3c 100644 --- a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/pwmout_api.c +++ b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/pwmout_api.c @@ -22,15 +22,15 @@ static const PinMap PinMap_PWM[] = { // LEDs {LED_RED , PWM_3 , 3}, // PTC3, FTM0 CH2 - {LED_GREEN, PWM_5, 3}, // PTD4, FTM0 CH4 - {LED_BLUE , PWM_9 , 3}, // PTA2 , FTM0 CH7 + {LED_GREEN, PWM_5, 3}, // PTD4, FTM0 CH4 + {LED_BLUE , PWM_8 , 3}, // PTA2, FTM0 CH7 // Arduino digital pinout {D3, PWM_5 , 3}, // PTD4, FTM0 CH4 - {D5, PWM_7 , 3}, // PTA1 , FTM0 CH6 - {D6, PWM_3 , 3}, // PTC3 , FTM0 CH2 - {D9, PWM_8 , 4}, // PTD2 , FTM0 CH7 - {D10, PWM_2 , 4}, // PTC2 , FTM0 CH1 + {D5, PWM_7 , 3}, // PTA1, FTM0 CH6 + {D6, PWM_3 , 3}, // PTC3, FTM0 CH2 + {D9, PWM_8 , 4}, // PTD2, FTM0 CH7 + {D10, PWM_2 , 4}, // PTC2, FTM0 CH1 {NC , NC , 0} }; @@ -54,10 +54,9 @@ void pwmout_init(pwmout_t* obj, PinName pin) { ftm->MODE |= FTM_MODE_WPDIS_MASK; //write protection disabled ftm->CONF |= FTM_CONF_BDMMODE(3); ftm->SC = FTM_SC_CLKS(1) | FTM_SC_PS(6); // (48)MHz / 64 = (0.75)MHz + ftm->PWMLOAD |= FTM_PWMLOAD_LDOK_MASK; ftm->CONTROLS[ch_n].CnSC = (FTM_CnSC_MSB_MASK | FTM_CnSC_ELSB_MASK); /* No Interrupts; High True pulses on Edge Aligned PWM */ - ftm->PWMLOAD |= FTM_PWMLOAD_LDOK_MASK; //loading updated values enabled - //ftm->SYNCONF |= FTM_SYNCONF_SWRSTCNT_MASK; - ftm->MODE |= FTM_MODE_INIT_MASK; + ftm->SYNCONF |= FTM_SYNCONF_SYNCMODE_MASK | FTM_SYNCONF_SWWRBUF_MASK; //enhanced obj->CnV = &ftm->CONTROLS[ch_n].CnV; obj->MOD = &ftm->MOD; @@ -66,7 +65,7 @@ void pwmout_init(pwmout_t* obj, PinName pin) { // default to 20ms: standard for servos, and fine for e.g. brightness control pwmout_period_ms(obj, 20); - pwmout_write (obj, 0); + pwmout_write(obj, 0); // Wire pinout pinmap_pinout(pin, PinMap_PWM); @@ -83,7 +82,7 @@ void pwmout_write(pwmout_t* obj, float value) { *obj->CnV = (uint32_t)((float)(*obj->MOD) * value); *obj->CNT = 0; - //*obj->SYNC |= FTM_SYNC_SWSYNC_MASK; + *obj->SYNC |= FTM_SYNC_SWSYNC_MASK; } float pwmout_read(pwmout_t* obj) { @@ -116,4 +115,5 @@ void pwmout_pulsewidth_ms(pwmout_t* obj, int ms) { void pwmout_pulsewidth_us(pwmout_t* obj, int us) { *obj->CnV = PWM_CLOCK_MHZ * us; + *obj->SYNC |= FTM_SYNC_SWSYNC_MASK; } From 5d95041620375aa7b080b921f164c127303f0095 Mon Sep 17 00:00:00 2001 From: 0xc0170 Date: Mon, 6 Jan 2014 18:43:17 +0100 Subject: [PATCH 03/24] PWM - legacy mode, LOAD use for updating --- .../targets/hal/TARGET_Freescale/TARGET_K20D5M/objects.h | 2 +- .../hal/TARGET_Freescale/TARGET_K20D5M/pwmout_api.c | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/objects.h b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/objects.h index 69bc95d6e1..d029cc5ebe 100644 --- a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/objects.h +++ b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/objects.h @@ -43,7 +43,7 @@ struct pwmout_s { __IO uint32_t *MOD; __IO uint32_t *CNT; __IO uint32_t *CnV; - __IO uint32_t *SYNC; + __IO uint32_t *PWMLOAD; }; struct serial_s { diff --git a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/pwmout_api.c b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/pwmout_api.c index 6c362e0e3c..899c75ca14 100644 --- a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/pwmout_api.c +++ b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/pwmout_api.c @@ -54,14 +54,12 @@ void pwmout_init(pwmout_t* obj, PinName pin) { ftm->MODE |= FTM_MODE_WPDIS_MASK; //write protection disabled ftm->CONF |= FTM_CONF_BDMMODE(3); ftm->SC = FTM_SC_CLKS(1) | FTM_SC_PS(6); // (48)MHz / 64 = (0.75)MHz - ftm->PWMLOAD |= FTM_PWMLOAD_LDOK_MASK; ftm->CONTROLS[ch_n].CnSC = (FTM_CnSC_MSB_MASK | FTM_CnSC_ELSB_MASK); /* No Interrupts; High True pulses on Edge Aligned PWM */ - ftm->SYNCONF |= FTM_SYNCONF_SYNCMODE_MASK | FTM_SYNCONF_SWWRBUF_MASK; //enhanced obj->CnV = &ftm->CONTROLS[ch_n].CnV; obj->MOD = &ftm->MOD; obj->CNT = &ftm->CNT; - obj->SYNC = &ftm->SYNC; + obj->PWMLOAD = &ftm->PWMLOAD; // default to 20ms: standard for servos, and fine for e.g. brightness control pwmout_period_ms(obj, 20); @@ -81,8 +79,8 @@ void pwmout_write(pwmout_t* obj, float value) { } *obj->CnV = (uint32_t)((float)(*obj->MOD) * value); + *obj->PWMLOAD |= FTM_PWMLOAD_LDOK_MASK; *obj->CNT = 0; - *obj->SYNC |= FTM_SYNC_SWSYNC_MASK; } float pwmout_read(pwmout_t* obj) { @@ -115,5 +113,5 @@ void pwmout_pulsewidth_ms(pwmout_t* obj, int ms) { void pwmout_pulsewidth_us(pwmout_t* obj, int us) { *obj->CnV = PWM_CLOCK_MHZ * us; - *obj->SYNC |= FTM_SYNC_SWSYNC_MASK; + *obj->PWMLOAD |= FTM_PWMLOAD_LDOK_MASK; } From b5527ca74d5ea8549ac55d75e5dd8d2939b9a9ce Mon Sep 17 00:00:00 2001 From: Bogdan Marinescu Date: Tue, 7 Jan 2014 15:57:49 +0200 Subject: [PATCH 04/24] [LPC4088] Switch to 'hard' FP ABI on GCC This is consistent with the armcc compilation options. --- workspace_tools/export/codered_lpc4088_cproject.tmpl | 8 ++++---- workspace_tools/export/gcc_arm_lpc4088.tmpl | 2 +- workspace_tools/toolchains/gcc.py | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/workspace_tools/export/codered_lpc4088_cproject.tmpl b/workspace_tools/export/codered_lpc4088_cproject.tmpl index 173fea11f1..9b05351086 100644 --- a/workspace_tools/export/codered_lpc4088_cproject.tmpl +++ b/workspace_tools/export/codered_lpc4088_cproject.tmpl @@ -41,7 +41,7 @@ {% endfor %} - - -