Skip to content

Commit fba060e

Browse files
authored
[stm32 pandora] fix the bug when using LCD demo (#5692)
* [stm32 pandora] fix the bug when using LCD demo * arduino 增加内部温度传感器和参考电压通道 * remove ARDUINO_PINOUT_PWM_MAX
1 parent f3b72aa commit fba060e

File tree

9 files changed

+47
-37
lines changed

9 files changed

+47
-37
lines changed

bsp/stm32/stm32f072-st-nucleo/applications/arduino/pins_arduino.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
*/
2121
const pin_map_t pin_map_table[]=
2222
{
23-
{D0, GET_PIN(A,3)}, /* RX */
24-
{D1, GET_PIN(A,2)}, /* TX */
23+
{D0}, /* RX */
24+
{D1}, /* TX */
2525
{D2, GET_PIN(A,10)},
2626
{D3, GET_PIN(B,3), "pwm2", 2}, /* PWM */
27-
{D4, GET_PIN(B,5)}, /* D4 */
27+
{D4, GET_PIN(B,5)},
2828
{D5, GET_PIN(B,4), "pwm3", 1}, /* PWM */
2929
{D6, GET_PIN(B,10), "pwm2", 3}, /* PWM */
3030
{D7, GET_PIN(A,8)},
@@ -36,12 +36,12 @@ const pin_map_t pin_map_table[]=
3636
{D13, GET_PIN(A,5)},
3737
{D14, GET_PIN(B,9)},
3838
{D15, GET_PIN(B,8)},
39-
{A0, GET_PIN(A,0), "adc1", 0},
40-
{A1, GET_PIN(A,1), "adc1", 1},
41-
{A2, GET_PIN(A,4), "adc1", 4},
42-
{A3, GET_PIN(B,0), "adc1", 8},
43-
{A4, GET_PIN(C,1), "adc1", 11},
44-
{A5, GET_PIN(C,0), "adc1", 10}
39+
{A0, GET_PIN(A,0), "adc1", 0}, /* ADC */
40+
{A1, GET_PIN(A,1), "adc1", 1}, /* ADC */
41+
{A2, GET_PIN(A,4), "adc1", 4}, /* ADC */
42+
{A3, GET_PIN(B,0), "adc1", 8}, /* ADC */
43+
{A4, GET_PIN(C,1), "adc1", 11}, /* ADC */
44+
{A5, GET_PIN(C,0), "adc1", 10} /* ADC */
4545
};
4646

4747
/* initialization for BSP; maybe a blank function */

bsp/stm32/stm32f072-st-nucleo/applications/arduino/pins_arduino.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636

3737
#define LED_BUILTIN D13 /* Built-in LED */
3838

39-
#define ARDUINO_PINOUT_PWM_MAX 5 /* This Arduino variant has 5 PWM pins */
4039
#define ARDUINO_PWM_HZ 500 /* Arduino UNO's PWM is around 500Hz */
4140

4241
#define ARDUINO_DEFAULT_IIC_BUS_NAME "i2c4"

bsp/stm32/stm32l475-atk-pandora/applications/arduino/pins_arduino.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,10 @@ const pin_map_t pin_map_table[]=
4444
{D21, GET_PIN(E,7)}, /* BSP: RED-LED */
4545
{D22, GET_PIN(E,8)}, /* LED_BUILTIN, BSP: GREEN-LED */
4646
{D23, GET_PIN(E,9), "pwm1", 1}, /* PWM, BSP: BLUE-LED */
47-
{A0, GET_PIN(C,2), "adc1", 3},
48-
{A1, GET_PIN(C,4), "adc1", 13},
49-
{A2},
50-
{A3},
51-
{A4},
52-
{A5}
47+
{A0, GET_PIN(C,2), "adc1", 3}, /* ADC */
48+
{A1, GET_PIN(C,4), "adc1", 13}, /* ADC */
49+
{A2, RT_NULL, "adc1", 0}, /* ADC, On-Chip: internal reference voltage */
50+
{A3, RT_NULL, "adc1", 17} /* ADC, On-Chip: internal temperature sensor */
5351
};
5452

5553
/* initialization for BSP; maybe a blank function */

bsp/stm32/stm32l475-atk-pandora/applications/arduino/pins_arduino.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,9 @@
3939
#define A1 (25)
4040
#define A2 (26)
4141
#define A3 (27)
42-
#define A4 (28)
43-
#define A5 (29)
4442

4543
#define LED_BUILTIN D22 /* Built-in LED */
4644

47-
#define ARDUINO_PINOUT_PWM_MAX 6 /* This Arduino variant has 6 PWM pins */
4845
#define ARDUINO_PWM_HZ 500 /* Arduino UNO's PWM is around 500Hz */
4946

5047
#define ARDUINO_DEFAULT_IIC_BUS_NAME "i2c4"

bsp/stm32/stm32l475-atk-pandora/board/CubeMX_Config/STM32L475VE.ioc

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,24 +78,26 @@ Mcu.Pin43=PB3 (JTDO-TRACESWO)
7878
Mcu.Pin44=PB5
7979
Mcu.Pin45=PB7
8080
Mcu.Pin46=PB8
81-
Mcu.Pin47=VP_IWDG_VS_IWDG
82-
Mcu.Pin48=VP_LPTIM1_VS_LPTIM_counterModeInternalClock
83-
Mcu.Pin49=VP_RTC_VS_RTC_Activate
81+
Mcu.Pin47=VP_ADC1_TempSens_Input
82+
Mcu.Pin48=VP_ADC1_Vref_Input
83+
Mcu.Pin49=VP_IWDG_VS_IWDG
8484
Mcu.Pin5=PC14-OSC32_IN (PC14)
85-
Mcu.Pin50=VP_SAI1_VP_$IpInstance_SAIA_SAI_BASIC
86-
Mcu.Pin51=VP_SAI1_VP_$IpInstance_SAIB_SAI_BASIC
87-
Mcu.Pin52=VP_SYS_VS_Systick
88-
Mcu.Pin53=VP_TIM1_VS_ClockSourceINT
89-
Mcu.Pin54=VP_TIM2_VS_ClockSourceINT
90-
Mcu.Pin55=VP_TIM4_VS_ClockSourceINT
91-
Mcu.Pin56=VP_TIM15_VS_ClockSourceINT
92-
Mcu.Pin57=VP_TIM16_VS_ClockSourceINT
93-
Mcu.Pin58=VP_TIM17_VS_ClockSourceINT
85+
Mcu.Pin50=VP_LPTIM1_VS_LPTIM_counterModeInternalClock
86+
Mcu.Pin51=VP_RTC_VS_RTC_Activate
87+
Mcu.Pin52=VP_SAI1_VP_$IpInstance_SAIA_SAI_BASIC
88+
Mcu.Pin53=VP_SAI1_VP_$IpInstance_SAIB_SAI_BASIC
89+
Mcu.Pin54=VP_SYS_VS_Systick
90+
Mcu.Pin55=VP_TIM1_VS_ClockSourceINT
91+
Mcu.Pin56=VP_TIM2_VS_ClockSourceINT
92+
Mcu.Pin57=VP_TIM4_VS_ClockSourceINT
93+
Mcu.Pin58=VP_TIM15_VS_ClockSourceINT
94+
Mcu.Pin59=VP_TIM16_VS_ClockSourceINT
9495
Mcu.Pin6=PC15-OSC32_OUT (PC15)
96+
Mcu.Pin60=VP_TIM17_VS_ClockSourceINT
9597
Mcu.Pin7=PH0-OSC_IN (PH0)
9698
Mcu.Pin8=PH1-OSC_OUT (PH1)
9799
Mcu.Pin9=PC2
98-
Mcu.PinsNb=59
100+
Mcu.PinsNb=61
99101
Mcu.ThirdPartyNb=0
100102
Mcu.UserConstants=
101103
Mcu.UserName=STM32L475VETx
@@ -369,6 +371,10 @@ USART2.IPParameters=VirtualMode-Asynchronous
369371
USART2.VirtualMode-Asynchronous=VM_ASYNC
370372
USB_OTG_FS.IPParameters=VirtualMode
371373
USB_OTG_FS.VirtualMode=Device_Only
374+
VP_ADC1_TempSens_Input.Mode=IN-TempSens
375+
VP_ADC1_TempSens_Input.Signal=ADC1_TempSens_Input
376+
VP_ADC1_Vref_Input.Mode=IN-Vrefint
377+
VP_ADC1_Vref_Input.Signal=ADC1_Vref_Input
372378
VP_IWDG_VS_IWDG.Mode=IWDG_Activate
373379
VP_IWDG_VS_IWDG.Signal=IWDG_VS_IWDG
374380
VP_LPTIM1_VS_LPTIM_counterModeInternalClock.Mode=Counts__internal_clock_event_00

bsp/stm32/stm32l475-atk-pandora/board/ports/lcd/demo/lcd_sample.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212
#include <rtdevice.h>
1313
#include <board.h>
1414
#include <drv_lcd.h>
15-
#include <lcd_qrcode.h>
1615
#include "rttlogo.h"
16+
#ifdef BSP_USING_LCD_QRCODE
17+
#include <lcd_qrcode.h>
18+
#endif /* BSP_USING_LCD_QRCODE */
1719

1820
static int lcd_sample(void)
1921
{
@@ -24,7 +26,8 @@ static int lcd_sample(void)
2426
lcd_draw_line(0, 69+24, 240, 69+24);
2527
#ifdef BSP_USING_LCD_QRCODE
2628
lcd_show_qrcode(54, 69+24+6, 4, ECC_LOW, "https://www.rt-thread.org/", 4);
27-
#endif
29+
#endif /* BSP_USING_LCD_QRCODE */
30+
2831
return RT_EOK;
2932
}
3033
INIT_APP_EXPORT(lcd_sample);

bsp/stm32/stm32l475-atk-pandora/board/ports/lcd/drv_lcd.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,15 @@ void lcd_display_brightness(rt_uint8_t percent)
238238
{
239239
struct rt_device_pwm *pwm_dev;
240240

241+
if(percent > 100)
242+
{
243+
percent = 100;
244+
}
245+
241246
pwm_dev = (struct rt_device_pwm*)rt_device_find("pwm4");
242247
if(pwm_dev != RT_NULL)
243248
{
244-
rt_pwm_set(pwm_dev, 2, 1000000, percent*10000); /* PWM4 CH2 with 1000Hz */
249+
rt_pwm_set(pwm_dev, 2, 1000000, percent*10000); /* PB7, PWM4 CH2 with 1000Hz */
245250
rt_pwm_enable(pwm_dev, 2);
246251
}
247252
}

bsp/stm32/stm32l475-atk-pandora/board/ports/lcd/lcd_qrcode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ static void show_qrcode_by_line(rt_uint16_t x, rt_uint16_t y, rt_uint8_t size, r
105105
*
106106
* @param x x position
107107
* @param y y position
108-
* @param version version of qrcode
108+
* @param version version of qrcode (ECC_LOW, ECC_MEDIUM, ECC_QUARTILE or ECC_HIGH)
109109
* @param ecc level of error correction
110110
* @param data string
111111
* @param enlargement enlargement_factor

bsp/stm32/stm32l475-atk-pandora/board/ports/lcd/lcd_qrcode.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55

66
#ifdef BSP_USING_LCD_QRCODE
77
#include <rtdef.h>
8+
#include <qrcode.h>
9+
810
rt_err_t lcd_show_qrcode(rt_uint16_t x, rt_uint16_t y, rt_uint8_t version, rt_uint8_t ecc, const char *data, rt_uint8_t enlargement);
9-
#endif
11+
#endif /* BSP_USING_LCD_QRCODE */
1012

1113
#endif

0 commit comments

Comments
 (0)