Skip to content

Commit 82b58af

Browse files
committed
Merge pull request #162 from bcostm/master
[NUCLEO_F401RE] Corrections in uvision exporter, GPIOs setting and SPI.
2 parents c19ed4c + ddce5e7 commit 82b58af

File tree

6 files changed

+22
-24
lines changed

6 files changed

+22
-24
lines changed

libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/spi_api.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ static const PinMap PinMap_SPI_SCLK[] = {
5757
// Only used in Slave mode
5858
static const PinMap PinMap_SPI_SSEL[] = {
5959
{PB_6, SPI_1, STM_PIN_DATA(GPIO_Mode_IN_FLOATING, 0)}, // Generic IO, not real H/W NSS pin
60-
//{PA_4, SPI_1, STM_PIN_DATA(GPIO_Mode_IN_FLOATING, 0)},
61-
//{PA_15, SPI_1, STM_PIN_DATA(GPIO_Mode_IN_FLOATING, 1)}, // Remap
6260
{NC, NC, 0}
6361
};
6462

@@ -102,9 +100,6 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel
102100
if (obj->spi == SPI_1) {
103101
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1, ENABLE);
104102
}
105-
if (obj->spi == SPI_2) {
106-
RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI2, ENABLE);
107-
}
108103

109104
// Configure the SPI pins
110105
pinmap_pinout(mosi, PinMap_SPI_MOSI);
@@ -115,7 +110,7 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel
115110
obj->bits = SPI_DataSize_8b;
116111
obj->cpol = SPI_CPOL_Low;
117112
obj->cpha = SPI_CPHA_1Edge;
118-
obj->br_presc = SPI_BaudRatePrescaler_64; // Closest to 1MHz (72MHz/64 = 1.125MHz)
113+
obj->br_presc = SPI_BaudRatePrescaler_256; // 1MHz
119114

120115
if (ssel == NC) { // Master
121116
obj->mode = SPI_Mode_Master;
@@ -176,11 +171,8 @@ void spi_format(spi_t *obj, int bits, int mode, int slave) {
176171
}
177172

178173
void spi_frequency(spi_t *obj, int hz) {
179-
// Get SPI clock frequency
180-
uint32_t PCLK = SystemCoreClock >> 1;
181-
182174
// Choose the baud rate divisor (between 2 and 256)
183-
uint32_t divisor = PCLK / hz;
175+
uint32_t divisor = SystemCoreClock / hz;
184176

185177
// Find the nearest power-of-2
186178
divisor = (divisor > 0 ? divisor-1 : 0);

libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/i2c_api.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@
4343
#define LONG_TIMEOUT ((int)0x8000)
4444

4545
static const PinMap PinMap_I2C_SDA[] = {
46-
{PB_9, I2C_1, STM_PIN_DATA(GPIO_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)},
46+
{PB_9, I2C_1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)},
4747
{NC, NC, 0}
4848
};
4949

5050
static const PinMap PinMap_I2C_SCL[] = {
51-
{PB_8, I2C_1, STM_PIN_DATA(GPIO_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)},
51+
{PB_8, I2C_1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)},
5252
{NC, NC, 0}
5353
};
5454

libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/pwmout_api.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@
3535
#include "stm32f4xx_hal.h"
3636

3737
static const PinMap PinMap_PWM[] = {
38-
{PB_3, PWM_2, STM_PIN_DATA(GPIO_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2)}, // TIM2_CH2
39-
{PB_4, PWM_3, STM_PIN_DATA(GPIO_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3)}, // TIM3_CH1
40-
{PB_6, PWM_4, STM_PIN_DATA(GPIO_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4)}, // TIM4_CH1
38+
{PB_3, PWM_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2)}, // TIM2_CH2
39+
{PB_4, PWM_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3)}, // TIM3_CH1
40+
{PB_6, PWM_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4)}, // TIM4_CH1
4141
{NC, NC, 0}
4242
};
4343

@@ -71,7 +71,7 @@ void pwmout_free(pwmout_t* obj) {
7171

7272
HAL_TIM_PWM_DeInit(&TimHandle);
7373

74-
pin_function(obj->pin, STM_PIN_DATA(GPIO_MODE_INPUT, GPIO_NOPULL, 0));
74+
pin_function(obj->pin, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 0));
7575
}
7676

7777
void pwmout_write(pwmout_t* obj, float value) {

libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/spi_api.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,23 @@
3838
#include "stm32f4xx_hal.h"
3939

4040
static const PinMap PinMap_SPI_MOSI[] = {
41-
{PA_7, SPI_1, STM_PIN_DATA(GPIO_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
41+
{PA_7, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
4242
{NC, NC, 0}
4343
};
4444

4545
static const PinMap PinMap_SPI_MISO[] = {
46-
{PA_6, SPI_1, STM_PIN_DATA(GPIO_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
46+
{PA_6, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
4747
{NC, NC, 0}
4848
};
4949

5050
static const PinMap PinMap_SPI_SCLK[] = {
51-
{PA_5, SPI_1, STM_PIN_DATA(GPIO_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
51+
{PA_5, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
5252
{NC, NC, 0}
5353
};
5454

5555
// Only used in Slave mode
5656
static const PinMap PinMap_SPI_SSEL[] = {
57-
{PB_6, SPI_1, STM_PIN_DATA(GPIO_MODE_INPUT, GPIO_NOPULL, 0)}, // Generic IO, not real H/W NSS pin
57+
{PB_6, SPI_1, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 0)}, // Generic IO, not real H/W NSS pin
5858
{NC, NC, 0}
5959
};
6060

workspace_tools/export/uvision4.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
class Uvision4(Exporter):
2222
NAME = 'uVision4'
2323

24-
TARGETS = ['LPC1768', 'LPC11U24', 'KL05Z', 'KL25Z', 'KL46Z', 'K20D5M', 'LPC1347', 'LPC1114', 'LPC11C24', 'LPC4088', 'LPC812', 'NUCLEO_F103RB', 'NUCLEO_L152RE', 'NUCLEO_F030R8', 'C027']
24+
TARGETS = ['LPC1768', 'LPC11U24', 'KL05Z', 'KL25Z', 'KL46Z', 'K20D5M', 'LPC1347', 'LPC1114', 'LPC11C24', 'LPC4088', 'LPC812', 'NUCLEO_F103RB', 'NUCLEO_L152RE', 'NUCLEO_F030R8', 'NUCLEO_F401RE', 'C027']
2525

26-
USING_MICROLIB = ['LPC11U24', 'LPC1114', 'LPC11C24', 'LPC812', 'NUCLEO_F103RB', 'NUCLEO_L152RE', 'NUCLEO_F030R8']
26+
USING_MICROLIB = ['LPC11U24', 'LPC1114', 'LPC11C24', 'LPC812', 'NUCLEO_F103RB', 'NUCLEO_L152RE', 'NUCLEO_F030R8', 'NUCLEO_F401RE']
2727

2828
FILE_TYPES = {
2929
'c_sources':'1',

workspace_tools/export/uvision4_nucleo_f103rb.uvproj.tmpl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
<SLE66AMisc></SLE66AMisc>
3131
<SLE66LinkerMisc></SLE66LinkerMisc>
3232
<SFDFile>SFD\ST\STM32F1xx\STM32F103xx.sfr</SFDFile>
33+
<bCustSvd>0</bCustSvd>
3334
<UseEnv>0</UseEnv>
3435
<BinPath></BinPath>
3536
<IncludePath></IncludePath>
@@ -97,6 +98,7 @@
9798
<StopOnExitCode>3</StopOnExitCode>
9899
<CustomArgument></CustomArgument>
99100
<IncludeLibraryModules></IncludeLibraryModules>
101+
<ComprImg>1</ComprImg>
100102
</CommonProperty>
101103
<DllOption>
102104
<SimDllName>SARMCM3.DLL</SimDllName>
@@ -163,12 +165,16 @@
163165
<RunIndependent>0</RunIndependent>
164166
<UpdateFlashBeforeDebugging>1</UpdateFlashBeforeDebugging>
165167
<Capability>1</Capability>
166-
<DriverSelection>4104</DriverSelection>
168+
<DriverSelection>4103</DriverSelection>
167169
</Flash1>
168170
<bUseTDR>1</bUseTDR>
169-
<Flash2>BIN\CMSIS_AGDI.dll</Flash2>
171+
<Flash2>STLink\ST-LINKIII-KEIL_SWO.dll</Flash2>
170172
<Flash3>"" ()</Flash3>
171173
<Flash4></Flash4>
174+
<pFcarmOut></pFcarmOut>
175+
<pFcarmGrp></pFcarmGrp>
176+
<pFcArmRoot></pFcArmRoot>
177+
<FcArmLst>0</FcArmLst>
172178
</Utilities>
173179
<TargetArmAds>
174180
<ArmAdsMisc>

0 commit comments

Comments
 (0)