diff options
author | Damien George <damien.p.george@gmail.com> | 2015-07-22 19:37:21 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2015-07-22 19:41:13 +0100 |
commit | 7693ef3bd6e4456105c86909174a00f535a19261 (patch) | |
tree | 10e802dc6fd2aa502ed7bea85a147027205c3dbd /stmhal/dac.c | |
parent | 99a21dc05d7c7e42131264259f287c84afe86200 (diff) |
stmhal: Allow ADC.read_timed to take Timer object in place of freq.
This allows a user-specified Timer for the triggering of the ADC read,
mirroring the new behaviour of DAC.write_timed.
Addresses issue #1129.
Diffstat (limited to 'stmhal/dac.c')
-rw-r--r-- | stmhal/dac.c | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/stmhal/dac.c b/stmhal/dac.c index d71543ff2..b1e688442 100644 --- a/stmhal/dac.c +++ b/stmhal/dac.c @@ -80,25 +80,20 @@ void dac_init(void) { #if defined(TIM6) STATIC void TIM6_Config(uint freq) { // Init TIM6 at the required frequency (in Hz) - timer_tim6_init(freq); + TIM_HandleTypeDef *tim = timer_tim6_init(freq); // TIM6 TRGO selection TIM_MasterConfigTypeDef config; config.MasterOutputTrigger = TIM_TRGO_UPDATE; config.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; - HAL_TIMEx_MasterConfigSynchronization(&TIM6_Handle, &config); + HAL_TIMEx_MasterConfigSynchronization(tim, &config); // TIM6 start counter - HAL_TIM_Base_Start(&TIM6_Handle); + HAL_TIM_Base_Start(tim); } #endif STATIC uint32_t TIMx_Config(mp_obj_t timer) { - // make sure the given object is a timer - if (mp_obj_get_type(timer) != &pyb_timer_type) { - nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "need a Timer object")); - } - // TRGO selection to trigger DAC TIM_HandleTypeDef *tim = pyb_timer_get_handle(timer); TIM_MasterConfigTypeDef config; |