Browse Source

HAL_ChibiOS: modify hwdef scripts to setup for generic RCIN

mission-4.1.18
bugobliterator 7 years ago committed by Andrew Tridgell
parent
commit
1db1ff799e
  1. 30
      libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py
  2. 2
      libraries/AP_HAL_ChibiOS/hwdef/scripts/dma_resolver.py

30
libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py

@ -462,27 +462,31 @@ def write_I2C_config(f):
def write_PWM_config(f): def write_PWM_config(f):
'''write PWM config defines''' '''write PWM config defines'''
ppm_in = None rc_in = None
pwm_out = [] pwm_out = []
pwm_timers = [] pwm_timers = []
for l in bylabel.keys(): for l in bylabel.keys():
p = bylabel[l] p = bylabel[l]
if p.type.startswith('TIM'): if p.type.startswith('TIM'):
if p.has_extra('PPMIN'): if p.has_extra('RCIN'):
ppm_in = p rc_in = p
else: else:
if p.extra_value('PWM', type=int) is not None: if p.extra_value('PWM', type=int) is not None:
pwm_out.append(p) pwm_out.append(p)
if p.type not in pwm_timers: if p.type not in pwm_timers:
pwm_timers.append(p.type) pwm_timers.append(p.type)
if ppm_in is not None: if rc_in is not None:
chan = int(ppm_in.label[7:]) if int(rc_in.label[7:]) not in [1,2]:
n = int(ppm_in.type[3]) error("Bad channel number, only channel 1 and 2 supported for RCIN")
f.write('// PPM input config\n') n = int(rc_in.type[3])
f.write('#define HAL_USE_EICU TRUE\n') dma_chan_str = rc_in.extra_prefix('DMA_CH')[6:]
f.write('#define PPM_EICU_TIMER EICUD%u\n' % n) dma_chan = int(dma_chan_str)
f.write('#define STM32_EICU_USE_TIM%u TRUE\n' % n) f.write('// RC input config\n')
f.write('#define PPM_EICU_CHANNEL EICU_CHANNEL_%u\n' % chan) f.write('#define HAL_USE_ICU TRUE\n')
f.write('#define STM32_ICU_USE_TIM%u TRUE\n' % n)
f.write('#define RCIN_ICU_TIMER ICUD%u\n' % n)
f.write('#define RCIN_ICU_CHANNEL ICU_CHANNEL_%u\n' % int(rc_in.label[7:]))
f.write('#define STM32_RCIN_DMA_CHANNEL %u' % dma_chan)
f.write('\n') f.write('\n')
f.write('// PWM timer config\n') f.write('// PWM timer config\n')
for t in sorted(pwm_timers): for t in sorted(pwm_timers):
@ -728,7 +732,9 @@ def build_peripheral_list():
if type.startswith('ADC'): if type.startswith('ADC'):
peripherals.append(type) peripherals.append(type)
if type.startswith('SDIO'): if type.startswith('SDIO'):
peripherals.append(type) peripherals.append(type)
if type.startswith('TIM') and p.has_extra('RCIN'):
peripherals.append(p.label)
done.add(type) done.add(type)
return peripherals return peripherals

2
libraries/AP_HAL_ChibiOS/hwdef/scripts/dma_resolver.py

@ -61,6 +61,8 @@ def chibios_dma_define_name(key):
return 'STM32_UART_%s_DMA_STREAM' % key return 'STM32_UART_%s_DMA_STREAM' % key
elif key.startswith('SDIO'): elif key.startswith('SDIO'):
return 'STM32_SDC_%s_DMA_STREAM' % key return 'STM32_SDC_%s_DMA_STREAM' % key
elif key.startswith('TIM'):
return 'STM32_RCIN_DMA_STREAM'
else: else:
print("Error: Unknown key type %s" % key) print("Error: Unknown key type %s" % key)
sys.exit(1) sys.exit(1)

Loading…
Cancel
Save