Skip to content

Commit 792677e

Browse files
committed
[NUCLEO_F103RB] Remove trailing spaces, typo corrections
1 parent 9ac0131 commit 792677e

File tree

16 files changed

+389
-427
lines changed

16 files changed

+389
-427
lines changed

libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/PeripheralNames.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ typedef enum {
4141
} ADCName;
4242

4343
typedef enum {
44-
UART_1 = (int)USART1_BASE,
44+
UART_1 = (int)USART1_BASE,
4545
UART_2 = (int)USART2_BASE,
4646
UART_3 = (int)USART3_BASE
4747
} UARTName;

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

Lines changed: 77 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@
2626
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2727
*/
2828
#include "analogin_api.h"
29-
#include "wait_api.h"
3029

3130
#if DEVICE_ANALOGIN
3231

3332
#include "cmsis.h"
3433
#include "pinmap.h"
3534
#include "error.h"
35+
#include "wait_api.h"
3636

3737
static const PinMap PinMap_ADC[] = {
3838
{PA_0, ADC_1, STM_PIN_DATA(GPIO_Mode_AIN, 0)}, // ADC12_IN0
@@ -57,15 +57,14 @@ static const PinMap PinMap_ADC[] = {
5757
int adc_inited = 0;
5858

5959
void analogin_init(analogin_t *obj, PinName pin) {
60-
61-
ADC_TypeDef *adc;
60+
ADC_TypeDef *adc;
6261
ADC_InitTypeDef ADC_InitStructure;
63-
62+
6463
// Get the peripheral name from the pin and assign it to the object
6564
obj->adc = (ADCName)pinmap_peripheral(pin, PinMap_ADC);
66-
65+
6766
if (obj->adc == (ADCName)NC) {
68-
error("ADC pin mapping failed");
67+
error("ADC pin mapping failed");
6968
}
7069

7170
// Configure GPIO
@@ -80,12 +79,12 @@ void analogin_init(analogin_t *obj, PinName pin) {
8079

8180
// Get ADC registers structure address
8281
adc = (ADC_TypeDef *)(obj->adc);
83-
82+
8483
// Enable ADC clock (14 MHz maximum)
8584
// PCLK2 = 64 MHz --> ADC clock = 64/6 = 10.666 MHz
8685
RCC_ADCCLKConfig(RCC_PCLK2_Div6);
8786
RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE);
88-
87+
8988
// Configure ADC
9089
ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;
9190
ADC_InitStructure.ADC_ScanConvMode = DISABLE;
@@ -100,87 +99,87 @@ void analogin_init(analogin_t *obj, PinName pin) {
10099

101100
// Calibrate ADC
102101
ADC_ResetCalibration(adc);
103-
while(ADC_GetResetCalibrationStatus(adc));
102+
while (ADC_GetResetCalibrationStatus(adc));
104103
ADC_StartCalibration(adc);
105-
while(ADC_GetCalibrationStatus(adc));
104+
while (ADC_GetCalibrationStatus(adc));
106105
}
107106
}
108107

109108
static inline uint16_t adc_read(analogin_t *obj) {
110-
// Get ADC registers structure address
111-
ADC_TypeDef *adc = (ADC_TypeDef *)(obj->adc);
112-
int channel = 0;
113-
114-
// Configure ADC channel
115-
switch (obj->pin) {
116-
case PA_0:
117-
channel = 0;
118-
break;
119-
case PA_1:
120-
channel = 1;
121-
break;
122-
case PA_2:
123-
channel = 2;
124-
break;
125-
case PA_3:
126-
channel = 3;
127-
break;
128-
case PA_4:
129-
channel = 4;
130-
break;
131-
case PA_5:
132-
channel = 5;
133-
break;
134-
case PA_6:
135-
channel = 6;
136-
break;
137-
case PA_7:
138-
channel = 7;
139-
break;
140-
case PB_0:
141-
channel = 8;
142-
break;
143-
case PB_1:
144-
channel = 9;
145-
break;
146-
case PC_0:
147-
channel = 10;
148-
break;
149-
case PC_1:
150-
channel = 11;
151-
break;
152-
case PC_2:
153-
channel = 12;
154-
break;
155-
case PC_3:
156-
channel = 13;
157-
break;
158-
case PC_4:
159-
channel = 14;
160-
break;
161-
case PC_5:
162-
channel = 15;
163-
break;
164-
default:
165-
return 0;
166-
}
167-
168-
ADC_RegularChannelConfig(adc, channel, 1, ADC_SampleTime_7Cycles5);
169-
170-
ADC_SoftwareStartConvCmd(adc, ENABLE); // Start conversion
171-
172-
while(ADC_GetFlagStatus(adc, ADC_FLAG_EOC) == RESET); // Wait end of conversion
173-
174-
return(ADC_GetConversionValue(adc)); // Get conversion value
109+
// Get ADC registers structure address
110+
ADC_TypeDef *adc = (ADC_TypeDef *)(obj->adc);
111+
int channel = 0;
112+
113+
// Configure ADC channel
114+
switch (obj->pin) {
115+
case PA_0:
116+
channel = 0;
117+
break;
118+
case PA_1:
119+
channel = 1;
120+
break;
121+
case PA_2:
122+
channel = 2;
123+
break;
124+
case PA_3:
125+
channel = 3;
126+
break;
127+
case PA_4:
128+
channel = 4;
129+
break;
130+
case PA_5:
131+
channel = 5;
132+
break;
133+
case PA_6:
134+
channel = 6;
135+
break;
136+
case PA_7:
137+
channel = 7;
138+
break;
139+
case PB_0:
140+
channel = 8;
141+
break;
142+
case PB_1:
143+
channel = 9;
144+
break;
145+
case PC_0:
146+
channel = 10;
147+
break;
148+
case PC_1:
149+
channel = 11;
150+
break;
151+
case PC_2:
152+
channel = 12;
153+
break;
154+
case PC_3:
155+
channel = 13;
156+
break;
157+
case PC_4:
158+
channel = 14;
159+
break;
160+
case PC_5:
161+
channel = 15;
162+
break;
163+
default:
164+
return 0;
165+
}
166+
167+
ADC_RegularChannelConfig(adc, channel, 1, ADC_SampleTime_7Cycles5);
168+
169+
ADC_SoftwareStartConvCmd(adc, ENABLE); // Start conversion
170+
171+
while (ADC_GetFlagStatus(adc, ADC_FLAG_EOC) == RESET); // Wait end of conversion
172+
173+
return (ADC_GetConversionValue(adc)); // Get conversion value
175174
}
176175

177176
uint16_t analogin_read_u16(analogin_t *obj) {
178-
return(adc_read(obj));
177+
return (adc_read(obj));
179178
}
180179

181180
float analogin_read(analogin_t *obj) {
182-
uint16_t value = adc_read(obj);
183-
return (float)value * (1.0f / (float)0xFFF); // 12 bits range
181+
uint16_t value = adc_read(obj);
182+
return (float)value * (1.0f / (float)0xFFF); // 12 bits range
184183
}
185184

186185
#endif

libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/device.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@
3737
#define DEVICE_INTERRUPTIN 1
3838

3939
#define DEVICE_ANALOGIN 1
40-
#define DEVICE_ANALOGOUT 0
40+
#define DEVICE_ANALOGOUT 0 // Not present on this device
4141

4242
#define DEVICE_SERIAL 1
4343

4444
#define DEVICE_I2C 1
45-
#define DEVICE_I2CSLAVE 0
45+
#define DEVICE_I2CSLAVE 0 // Not yet supported
4646

4747
#define DEVICE_SPI 1
48-
#define DEVICE_SPISLAVE 0
48+
#define DEVICE_SPISLAVE 0 // Not yet supported
4949

5050
#define DEVICE_RTC 1
5151

@@ -63,7 +63,7 @@
6363

6464
#define DEVICE_STDIO_MESSAGES 1
6565

66-
//#define DEVICE_ERROR_RED 0
66+
#define DEVICE_ERROR_RED 0
6767

6868
#include "objects.h"
6969

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
extern uint32_t Set_GPIO_Clock(uint32_t port_idx);
3535

36-
uint32_t gpio_set(PinName pin) {
36+
uint32_t gpio_set(PinName pin) {
3737
if (pin == NC) return 0;
3838

3939
pin_function(pin, STM_PIN_DATA(GPIO_Mode_IN_FLOATING, 0));
@@ -45,11 +45,11 @@ void gpio_init(gpio_t *obj, PinName pin) {
4545
if (pin == NC) return;
4646

4747
uint32_t port_index = STM_PORT(pin);
48-
48+
4949
// Enable GPIO clock
5050
uint32_t gpio_add = Set_GPIO_Clock(port_index);
5151
GPIO_TypeDef *gpio = (GPIO_TypeDef *)gpio_add;
52-
52+
5353
// Fill GPIO object structure for future use
5454
obj->pin = pin;
5555
obj->mask = gpio_set(pin);
@@ -65,8 +65,7 @@ void gpio_mode(gpio_t *obj, PinMode mode) {
6565
void gpio_dir(gpio_t *obj, PinDirection direction) {
6666
if (direction == PIN_OUTPUT) {
6767
pin_function(obj->pin, STM_PIN_DATA(GPIO_Mode_Out_PP, 0));
68-
}
69-
else { // PIN_INPUT
68+
} else { // PIN_INPUT
7069
pin_function(obj->pin, STM_PIN_DATA(GPIO_Mode_IN_FLOATING, 0));
7170
}
7271
}

0 commit comments

Comments
 (0)