mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-30 19:47:50 +08:00
[modules] start adding MCU periph modules (#1989)
Modules for MCU peripherals. Previous subsystems or direct definition in firmware makefile are kept for now, until dependencies are properly handled.
This commit is contained in:
committed by
Felix Ruess
parent
b47c10fd00
commit
46bec882f3
@@ -1,2 +0,0 @@
|
|||||||
#generic i2c driver
|
|
||||||
$(error The i2c subsystem does not have to be specified explicitly anymore, it is always included now. Remove the line <subsystem name="i2c"/> from the firmware section of your airframe file!)
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
# Hey Emacs, this is a -*- makefile -*-
|
|
||||||
|
|
||||||
#generic spi driver
|
|
||||||
$(TARGET).CFLAGS += -DUSE_SPI -DSPI_SLAVE_HS
|
|
||||||
|
|
||||||
ifeq ($(TARGET), sim)
|
|
||||||
else
|
|
||||||
|
|
||||||
$(TARGET).srcs += mcu_periph/spi.c $(SRC_ARCH)/mcu_periph/spi_slave_hs_arch.c
|
|
||||||
|
|
||||||
endif
|
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<!DOCTYPE module SYSTEM "module.dtd">
|
||||||
|
|
||||||
|
<module name="adc" dir="mcu_periph" task="mcu">
|
||||||
|
<doc>
|
||||||
|
<description>
|
||||||
|
General ADC driver
|
||||||
|
To activate a specific ADC input, define flag USE_ADC_X where X is your ADC input number
|
||||||
|
</description>
|
||||||
|
</doc>
|
||||||
|
<header>
|
||||||
|
<file name="adc.h" dir="mcu_periph"/>
|
||||||
|
</header>
|
||||||
|
<makefile>
|
||||||
|
<define name="USE_ADC"/>
|
||||||
|
<file_arch name="adc_arch.c" dir="mcu_periph"/>
|
||||||
|
</makefile>
|
||||||
|
</module>
|
||||||
|
|
||||||
@@ -6,6 +6,7 @@
|
|||||||
<define name="CHIMU_BIG_ENDIAN" value="TRUE" description="For older CHIMU v1.0 you should define CHIMU_BIG_ENDIAN"/>
|
<define name="CHIMU_BIG_ENDIAN" value="TRUE" description="For older CHIMU v1.0 you should define CHIMU_BIG_ENDIAN"/>
|
||||||
</doc>
|
</doc>
|
||||||
<autoload name="ahrs_sim"/>
|
<autoload name="ahrs_sim"/>
|
||||||
|
<autoload name="spi" type="slave_hs"/>
|
||||||
<header>
|
<header>
|
||||||
<file name="ins_module.h"/>
|
<file name="ins_module.h"/>
|
||||||
</header>
|
</header>
|
||||||
@@ -21,8 +22,5 @@
|
|||||||
<file name="imu_chimu.c"/>
|
<file name="imu_chimu.c"/>
|
||||||
<file name="ahrs.c" dir="subsystems"/>
|
<file name="ahrs.c" dir="subsystems"/>
|
||||||
<define name="AHRS_TYPE_H" value="modules/ins/ahrs_chimu.h" type="string"/>
|
<define name="AHRS_TYPE_H" value="modules/ins/ahrs_chimu.h" type="string"/>
|
||||||
<raw>
|
|
||||||
include $(CFG_FIXEDWING)/spi_slave_hs.makefile
|
|
||||||
</raw>
|
|
||||||
</makefile>
|
</makefile>
|
||||||
</module>
|
</module>
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<!DOCTYPE module SYSTEM "module.dtd">
|
||||||
|
|
||||||
|
<module name="dac" dir="mcu_periph" task="mcu">
|
||||||
|
<doc>
|
||||||
|
<description>
|
||||||
|
General DAC driver
|
||||||
|
To activate a specific DAC input, define flag USE_DACX where X is your DAC input number
|
||||||
|
</description>
|
||||||
|
</doc>
|
||||||
|
<header>
|
||||||
|
<file name="dac.h" dir="mcu_periph"/>
|
||||||
|
</header>
|
||||||
|
<makefile>
|
||||||
|
<define name="USE_DAC"/>
|
||||||
|
<file_arch name="dac_arch.c" dir="mcu_periph"/>
|
||||||
|
</makefile>
|
||||||
|
</module>
|
||||||
|
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<!DOCTYPE module SYSTEM "module.dtd">
|
||||||
|
|
||||||
|
<module name="i2c" dir="mcu_periph" task="mcu">
|
||||||
|
<doc>
|
||||||
|
<description>
|
||||||
|
General I2C driver
|
||||||
|
To activate a specific I2C peripheral, define flag USE_I2CX where X is your I2C peripheral number
|
||||||
|
</description>
|
||||||
|
</doc>
|
||||||
|
<header>
|
||||||
|
<file name="i2c.h" dir="mcu_periph"/>
|
||||||
|
</header>
|
||||||
|
<makefile>
|
||||||
|
<file name="i2c.c" dir="mcu_periph"/>
|
||||||
|
<file_arch name="i2c_arch.c" dir="mcu_periph"/>
|
||||||
|
</makefile>
|
||||||
|
</module>
|
||||||
|
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
<!DOCTYPE module SYSTEM "module.dtd">
|
||||||
|
|
||||||
|
<module name="mcu" dir="mcu_periph" task="mcu">
|
||||||
|
<doc>
|
||||||
|
<description>
|
||||||
|
Automatic initialization module for all MCU peripherals
|
||||||
|
Also includes GPIO and LED drivers
|
||||||
|
</description>
|
||||||
|
</doc>
|
||||||
|
<header>
|
||||||
|
<file name="mcu.h" dir="."/>
|
||||||
|
<file name="gpio.h" dir="mcu_periph"/>
|
||||||
|
<file name="led.h" dir="."/>
|
||||||
|
</header>
|
||||||
|
<makefile>
|
||||||
|
<define name="PERIPHERALS_AUTO_INIT"/>
|
||||||
|
<defina name="USE_LED"/>
|
||||||
|
<file name="mcu.c" dir="."/>
|
||||||
|
<file_arch name="mcu_arch.c" dir="."/>
|
||||||
|
<file_arch name="armVIC.c" dir="." cond="ifeq ($(ARCH), lpc21)"/>
|
||||||
|
<file_arch name="gpio_arch.c" dir="mcu_periph" cond="ifeq ($(ARCH), stm32)"/>
|
||||||
|
<file_arch name="led_arch.c" dir="." cond="ifeq ($(ARCH), stm32)"/>
|
||||||
|
<file_arch name="gpio_arch.c" dir="mcu_periph" cond="ifeq ($(ARCH), chibios)"/>
|
||||||
|
<file_arch name="gpio_ardrone.c" dir="boards/ardrone" cond="ifeq ($(BOARD), ardrone)"/>
|
||||||
|
</makefile>
|
||||||
|
</module>
|
||||||
|
|
||||||
@@ -92,7 +92,8 @@ cond CDATA #IMPLIED>
|
|||||||
|
|
||||||
<!ATTLIST flag
|
<!ATTLIST flag
|
||||||
name CDATA #REQUIRED
|
name CDATA #REQUIRED
|
||||||
value CDATA #REQUIRED>
|
value CDATA #REQUIRED
|
||||||
|
cond CDATA #IMPLIED>
|
||||||
|
|
||||||
<!ATTLIST file
|
<!ATTLIST file
|
||||||
name CDATA #REQUIRED
|
name CDATA #REQUIRED
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<!DOCTYPE module SYSTEM "module.dtd">
|
||||||
|
|
||||||
|
<module name="spi_master" dir="mcu_periph" task="mcu">
|
||||||
|
<doc>
|
||||||
|
<description>
|
||||||
|
General SPI driver (master mode)
|
||||||
|
To activate a specific SPI peripheral, define flag USE_SPIX where X is your SPI peripheral number
|
||||||
|
</description>
|
||||||
|
</doc>
|
||||||
|
<header>
|
||||||
|
<file name="spi.h" dir="mcu_periph"/>
|
||||||
|
</header>
|
||||||
|
<makefile>
|
||||||
|
<define name="USE_SPI"/>
|
||||||
|
<define name="SPI_MASTER"/>
|
||||||
|
<file name="spi.c" dir="mcu_periph"/>
|
||||||
|
<file_arch name="spi_arch.c" dir="mcu_periph"/>
|
||||||
|
</makefile>
|
||||||
|
</module>
|
||||||
|
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<!DOCTYPE module SYSTEM "module.dtd">
|
||||||
|
|
||||||
|
<module name="spi_slave_hs" dir="mcu_periph" task="mcu">
|
||||||
|
<doc>
|
||||||
|
<description>
|
||||||
|
General SPI driver (high speed slave mode)
|
||||||
|
Only for fixedwing and boards based on LPC21
|
||||||
|
</description>
|
||||||
|
</doc>
|
||||||
|
<header>
|
||||||
|
<file name="spi.h" dir="mcu_periph"/>
|
||||||
|
</header>
|
||||||
|
<makefile target="!sim|nps" firmware="fixedwing">
|
||||||
|
<define name="USE_SPI"/>
|
||||||
|
<define name="SPI_SLAVE_HS"/>
|
||||||
|
<file name="spi.c" dir="mcu_periph"/>
|
||||||
|
<file_arch name="spi_slave_hs_arch.c" dir="mcu_periph"/>
|
||||||
|
</makefile>
|
||||||
|
</module>
|
||||||
|
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<!DOCTYPE module SYSTEM "module.dtd">
|
||||||
|
|
||||||
|
<module name="sys_time" dir="mcu_periph" task="mcu">
|
||||||
|
<doc>
|
||||||
|
<description>
|
||||||
|
Sys-time peripheral
|
||||||
|
</description>
|
||||||
|
<configure name="SYS_TIME_LED" value="none|num" value="LED number used for systime heartbeat or 'none' to disable"/>
|
||||||
|
</doc>
|
||||||
|
<header>
|
||||||
|
<file name="sys_time.h" dir="mcu_periph"/>
|
||||||
|
</header>
|
||||||
|
<makefile>
|
||||||
|
<configure name="SYS_TIME_LED" default="none"/>
|
||||||
|
<define name="SYS_TIME_LED" value="$(SYS_TIME_LED)" cond="ifneq ($(SYS_TIME_LED), none)"/>
|
||||||
|
<file name="sys_time.c" dir="mcu_periph"/>
|
||||||
|
<file_arch name="sys_time_arch.c" dir="mcu_periph"/>
|
||||||
|
<flag name="LDFLAGS" value="lrt" cond="ifeq ($(ARCH), linux)">
|
||||||
|
</makefile>
|
||||||
|
</module>
|
||||||
|
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<!DOCTYPE module SYSTEM "module.dtd">
|
||||||
|
|
||||||
|
<module name="uart" dir="mcu_periph" task="mcu">
|
||||||
|
<doc>
|
||||||
|
<description>
|
||||||
|
General UART driver
|
||||||
|
To activate a specific UART peripheral, define flag USE_UARTX where X is your UART peripheral number
|
||||||
|
</description>
|
||||||
|
</doc>
|
||||||
|
<header>
|
||||||
|
<file name="uart.h" dir="mcu_periph"/>
|
||||||
|
</header>
|
||||||
|
<makefile>
|
||||||
|
<file name="uart.c" dir="mcu_periph"/>
|
||||||
|
<file_arch name="uart_arch.c" dir="mcu_periph"/>
|
||||||
|
<file name="serial_port.c" dir="arch/linux" cond="ifeq ($(ARCH), linux)"/>
|
||||||
|
</makefile>
|
||||||
|
<makefile target="sim|nps">
|
||||||
|
<include name="arch/linux"/>
|
||||||
|
<file name="serial_port.c" dir="arch/linux"/>
|
||||||
|
</makefile>
|
||||||
|
</module>
|
||||||
|
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<!DOCTYPE module SYSTEM "module.dtd">
|
||||||
|
|
||||||
|
<module name="udp" dir="mcu_periph" task="mcu">
|
||||||
|
<doc>
|
||||||
|
<description>
|
||||||
|
General UDP driver
|
||||||
|
To activate a specific UDP peripheral, define flag USE_UDPX where X is your UDP peripheral number
|
||||||
|
</description>
|
||||||
|
</doc>
|
||||||
|
<header>
|
||||||
|
<file name="udp.h" dir="mcu_periph"/>
|
||||||
|
</header>
|
||||||
|
<makefile>
|
||||||
|
<define name="USE_UDP"/>
|
||||||
|
<file name="udp.c" dir="mcu_periph"/>
|
||||||
|
<file_arch name="udp_arch.c" dir="mcu_periph"/>
|
||||||
|
<file name="udp_socket.c" dir="arch/linux" cond="ifeq ($(ARCH), linux)"/>
|
||||||
|
</makefile>
|
||||||
|
<makefile target="nps">
|
||||||
|
<include name="arch/linux"/>
|
||||||
|
<file name="udp_socket.c" dir="arch/linux"/>
|
||||||
|
</makefile>
|
||||||
|
</module>
|
||||||
|
|
||||||
@@ -88,6 +88,16 @@ let include_xml2mk = fun f ?(target="$(TARGET)") ?(vpath=None) xml ->
|
|||||||
fprintf f "%s\n%s\nendif\n" cond flag
|
fprintf f "%s\n%s\nendif\n" cond flag
|
||||||
with Xml.No_attribute _ -> fprintf f "%s\n" flag
|
with Xml.No_attribute _ -> fprintf f "%s\n" flag
|
||||||
|
|
||||||
|
let flag_xml2mk = fun f ?(target="$(TARGET)") xml ->
|
||||||
|
let name = Xml.attrib xml "name"
|
||||||
|
and value = Xml.attrib xml "value" in
|
||||||
|
let flag = sprintf "%s.%s += -%s" target name value in
|
||||||
|
try
|
||||||
|
(* TODO: add condition in xml syntax ? *)
|
||||||
|
let cond = Xml.attrib xml "cond" in
|
||||||
|
fprintf f "%s\n%s\nendif\n" cond flag
|
||||||
|
with Xml.No_attribute _ -> fprintf f "%s\n" flag
|
||||||
|
|
||||||
let define_xml2mk = fun f ?(target="$(TARGET)") xml ->
|
let define_xml2mk = fun f ?(target="$(TARGET)") xml ->
|
||||||
let name = Xml.attrib xml "name"
|
let name = Xml.attrib xml "name"
|
||||||
and value = try Some (Xml.attrib xml "value") with _ -> None in
|
and value = try Some (Xml.attrib xml "value") with _ -> None in
|
||||||
@@ -185,10 +195,7 @@ let module_xml2mk = fun f target firmware m ->
|
|||||||
match Compat.bytes_lowercase (Xml.tag field) with
|
match Compat.bytes_lowercase (Xml.tag field) with
|
||||||
| "define" -> define_xml2mk f ~target field
|
| "define" -> define_xml2mk f ~target field
|
||||||
| "include" -> include_xml2mk f ~target ~vpath:m.vpath field
|
| "include" -> include_xml2mk f ~target ~vpath:m.vpath field
|
||||||
| "flag" ->
|
| "flag" -> flag_xml2mk f ~target field
|
||||||
let value = Xml.attrib field "value"
|
|
||||||
and name = Xml.attrib field "name" in
|
|
||||||
fprintf f "%s.%s += -%s\n" target name value
|
|
||||||
| "file" -> file_xml2mk f dir_name target field
|
| "file" -> file_xml2mk f dir_name target field
|
||||||
| "file_arch" -> file_xml2mk f ~arch:true dir_name target field
|
| "file_arch" -> file_xml2mk f ~arch:true dir_name target field
|
||||||
| "raw" -> raw_xml2mk f name field
|
| "raw" -> raw_xml2mk f name field
|
||||||
|
|||||||
Reference in New Issue
Block a user