Skip to content

Commit 8160370

Browse files
committed
Integrate latest libopencm3
1. use adc_calibrate 2. Change timer_reset to rcc_periph_reset_pulse
1 parent 449c81b commit 8160370

10 files changed

Lines changed: 18 additions & 21 deletions

File tree

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "libopencm3"]
2+
path = src/libopencm3
3+
url = https://github.com/DeviationTx/libopencm3.git

src/libopencm3

Submodule libopencm3 added at 7e1d3da

src/target/at9/power.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void PWR_Shutdown()
4343
printf("Shutdown\n");
4444
BACKLIGHT_Brightness(0);
4545
rcc_set_sysclk_source(RCC_CFGR_SW_SYSCLKSEL_HSICLK);
46-
rcc_wait_for_osc_ready(HSI);
46+
rcc_wait_for_osc_ready(RCC_HSI);
4747
while(1) ;
4848
}
4949

src/target/common/devo/power.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ void PWR_Shutdown()
5656
printf("Shutdown\n");
5757
BACKLIGHT_Brightness(0);
5858
rcc_set_sysclk_source(RCC_CFGR_SW_SYSCLKSEL_HSICLK);
59-
rcc_wait_for_osc_ready(HSI);
59+
rcc_wait_for_osc_ready(RCC_HSI);
6060
gpio_clear(_PWREN_PORT, _PWREN_PIN);
6161
while(1) ;
6262
}

src/target/common/devo/ppmin.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ void PPMin_TIM_Init()
5757

5858
/* Reset TIM1 peripheral. */
5959
timer_disable_counter(TIM1);
60-
timer_reset(TIM1);
60+
rcc_periph_reset_pulse(RST_TIM1);
6161

6262
/* Timer global mode:
6363
* - No divider

src/target/common/devo/protocol/pwm.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ void PWM_Initialize()
4848
// connect timer compare output to pin
4949
gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_50_MHZ, GPIO_CNF_OUTPUT_ALTFN_PUSHPULL, _PWM_PIN);
5050

51-
timer_reset(TIM1);
51+
rcc_periph_reset_pulse(RST_TIM1);
52+
5253
// Timer global mode: No divider, Alignment edge, Direction up, auto-preload buffered
5354
timer_set_mode(TIM1, TIM_CR1_CKD_CK_INT, TIM_CR1_CMS_EDGE, TIM_CR1_DIR_UP);
5455

src/target/common/devo/soft_serial.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ void SSER_Initialize()
6363

6464
// Configure bit timer
6565
rcc_peripheral_enable_clock(&RCC_APB1ENR, RCC_APB1ENR_TIM6EN);
66-
timer_reset(TIM6);
66+
rcc_periph_reset_pulse(RST_TIM6);
6767
nvic_set_priority(NVIC_TIM6_IRQ, 8);
6868
timer_set_prescaler(TIM6, 0);
6969
timer_enable_irq(TIM6, TIM_DIER_UIE);

src/target/common/stm32/adc.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ void ADC_Init(void)
2929
{
3030
rcc_peripheral_enable_clock(&RCC_APB2ENR, _RCC_APB2ENR_ADCEN);
3131
/* Make sure the ADC doesn't run during config. */
32-
adc_off(_ADC);
32+
adc_power_off(_ADC);
3333
rcc_peripheral_reset(&RCC_APB2RSTR, _RCC_APB2RSTR_ADCRST);
3434
rcc_peripheral_clear_reset(&RCC_APB2RSTR, _RCC_APB2RSTR_ADCRST);
3535
rcc_set_adcpre(RCC_CFGR_ADCPRE_PCLK2_DIV6);
@@ -41,12 +41,12 @@ void ADC_Init(void)
4141
adc_set_right_aligned(_ADC);
4242

4343
/* We want to read the temperature sensor, so we have to enable it. */
44-
adc_enable_temperature_sensor(_ADC);
44+
adc_enable_temperature_sensor();
4545
adc_set_sample_time_on_all_channels(_ADC, _ADC_SMPR_SMP_XXDOT5CYC);
4646

4747
adc_power_on(_ADC);
4848
adc_reset_calibration(_ADC);
49-
adc_calibration(_ADC);
49+
adc_calibrate(_ADC);
5050

5151
//Build a RNG seed using ADC 14, 16, 17
5252
for(int i = 0; i < 8; i++) {
@@ -58,7 +58,7 @@ void ADC_Init(void)
5858
//This is important. We're using the temp value as a buffer because otherwise the channel data
5959
//Can bleed into the voltage-sense data.
6060
//By disabling the temperature, we always read a consistent value
61-
adc_disable_temperature_sensor(_ADC);
61+
adc_disable_temperature_sensor();
6262
printf("RNG Seed: %08x\n", (int)rand32());
6363

6464
/* The following is based on code from here: http://code.google.com/p/rayaairbot */

src/target/common/stm32/clock.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,10 @@
3131
#define TIM_CONCAT(x, y, z) _TIM_CONCAT(x, y, z)
3232

3333
#define TIMx TIM_CONCAT(TIM, SYSCLK_TIM,)
34+
#define RST_TIMx TIM_CONCAT(RST_TIM, SYSCLK_TIM,)
3435
#define NVIC_TIMx_IRQ TIM_CONCAT(NVIC_TIM, SYSCLK_TIM, _IRQ)
3536
#define RCC_APB1ENR_TIMxEN TIM_CONCAT(RCC_APB1ENR_TIM, SYSCLK_TIM, EN)
3637
#define TIMx_ISR TIM_CONCAT(tim, SYSCLK_TIM, _isr)
37-
//The following is from an unreleased libopencm3
38-
//We should remove it eventually
39-
#if 1
40-
void iwdg_start(void);
41-
void iwdg_set_period_ms(u32 period);
42-
bool iwdg_reload_busy(void);
43-
bool iwdg_prescaler_busy(void);
44-
void iwdg_reset(void);
45-
#endif
4638

4739
volatile u32 msecs;
4840
volatile u32 wdg_time;
@@ -98,7 +90,7 @@ void CLOCK_Init()
9890

9991
timer_disable_counter(TIMx);
10092
/* Reset TIMx peripheral. */
101-
timer_reset(TIMx);
93+
rcc_periph_reset_pulse(RST_TIMx);
10294

10395
/* Timer global mode:
10496
* - No divider
@@ -281,7 +273,7 @@ void sys_tick_handler(void)
281273
// initialize RTC
282274
void RTC_Init()
283275
{
284-
rtc_auto_awake(LSE, 32767); // LowSpeed External source, divided by (clock-1)=32767
276+
rtc_auto_awake(RCC_LSE, 32767); // LowSpeed External source, divided by (clock-1)=32767
285277
}
286278

287279
// set date value (deviation epoch = seconds since 1.1.2012, 00:00:00)

src/target/x9d/adc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ void ADC_Init(void)
3030
{
3131
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_ADC1EN);
3232
/* Make sure the ADC doesn't run during config. */
33-
adc_off(ADC1);
33+
adc_power_off(ADC1);
3434
adc_set_clk_prescale(ADC_CCR_ADCPRE_BY2);
3535
/* We configure to scan the entire group each time conversion is requested. */
3636
adc_enable_scan_mode(ADC1);

0 commit comments

Comments
 (0)