Merge pull request #25 "Add support for C++ and fix some comments typo"

Merge remote-tracking branch 'schodet/master'

Conflicts:
	include/libopencm3/stm32/f1/adc.h
This commit is contained in:
Piotr Esden-Tempski 2012-09-10 12:21:21 -07:00
commit 02ea612142
42 changed files with 177 additions and 2 deletions

View File

@ -32,6 +32,16 @@ typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
/* This must be placed around external function declaration for C++
* support. */
#ifdef __cplusplus
# define BEGIN_DECLS extern "C" {
# define END_DECLS }
#else
# define BEGIN_DECLS
# define END_DECLS
#endif
/* Generic memory-mapped I/O accessor functions */
#define MMIO8(addr) (*(volatile u8 *)(addr))
#define MMIO16(addr) (*(volatile u16 *)(addr))

View File

@ -69,7 +69,11 @@
#define GPIO_CR(port) MMIO32(port + 0x524)
#define GPIO_AMSEL(port) MMIO32(port + 0x528)
BEGIN_DECLS
void gpio_set(u32 gpioport, u8 gpios);
void gpio_clear(u32 gpioport, u8 gpios);
END_DECLS
#endif

View File

@ -132,7 +132,11 @@
/* Overall interrupt status */
#define GPIO_IS MMIO32(GPIOINTERRPUT_BASE + 0x80)
BEGIN_DECLS
void gpio_set(u32 gpioport, u32 gpios);
void gpio_clear(u32 gpioport, u32 gpios);
END_DECLS
#endif

View File

@ -153,8 +153,12 @@
//TODO interrupts
BEGIN_DECLS
void gpio_set(u32 gpioport, u32 gpios);
void gpio_clear(u32 gpioport, u32 gpios);
void gpio_toggle(u32 gpioport, u32 gpios);
END_DECLS
#endif

View File

@ -131,7 +131,9 @@
#define I2C_WRITE 0
#define I2C_READ 1
/* --- I2C funtion prototypes----------------------------------------------- */
/* --- I2C function prototypes --------------------------------------------- */
BEGIN_DECLS
void i2c0_init(void);
void i2c0_tx_start(void);
@ -139,4 +141,6 @@ void i2c0_tx_byte(u8 byte);
u8 i2c0_rx_byte(void);
void i2c0_stop(void);
END_DECLS
#endif

View File

@ -134,6 +134,8 @@
/* --- NVIC functions ------------------------------------------------------ */
BEGIN_DECLS
void nvic_enable_irq(u8 irqn);
void nvic_disable_irq(u8 irqn);
u8 nvic_get_pending_irq(u8 irqn);
@ -144,4 +146,6 @@ u8 nvic_get_irq_enabled(u8 irqn);
void nvic_set_priority(u8 irqn, u8 priority);
void nvic_generate_software_interrupt(u8 irqn);
END_DECLS
#endif

View File

@ -725,6 +725,10 @@ typedef enum {
#define SCU_UART_RX_TX (SCU_CONF_EPUN_DIS_PULLUP | SCU_CONF_EPD_EN_PULLDOWN | SCU_CONF_EZI_EN_IN_BUFFER)
#define SCU_SSP_IO (SCU_CONF_EPUN_DIS_PULLUP | SCU_CONF_EHS_FAST | SCU_CONF_EZI_EN_IN_BUFFER | SCU_CONF_ZIF_DIS_IN_GLITCH_FILT)
BEGIN_DECLS
void scu_pinmux(scu_grp_pin_t group_pin, u32 scu_conf);
END_DECLS
#endif

View File

@ -157,6 +157,8 @@ typedef enum {
SSP_SLAVE_OUT_DISABLE = BIT3
} ssp_slave_option_t; /* This option is relevant only in slave mode */
BEGIN_DECLS
void ssp_disable(ssp_num_t ssp_num);
/*
@ -178,4 +180,6 @@ u16 ssp_read(ssp_num_t ssp_num);
void ssp_write(ssp_num_t ssp_num, u16 data);
END_DECLS
#endif

View File

@ -70,6 +70,8 @@
/* --- Function Prototypes ------------------------------------------------- */
BEGIN_DECLS
void systick_set_reload(u32 value);
u32 systick_get_value(void);
void systick_set_clocksource(u8 clocksource);
@ -81,4 +83,6 @@ u8 systick_get_countflag(void);
u32 systick_get_calib(void);
END_DECLS
#endif

View File

@ -615,6 +615,8 @@
/* --- CAN functions -------------------------------------------------------- */
BEGIN_DECLS
void can_reset(u32 canport);
int can_init(u32 canport, bool ttcm, bool abom, bool awum, bool nart,
bool rflm, bool txfp, u32 sjw, u32 ts1, u32 ts2, u32 brp);
@ -639,4 +641,6 @@ void can_receive(u32 canport, u8 fifo, bool release, u32 *id, bool *ext,
void can_fifo_release(u32 canport, u8 fifo);
END_DECLS
#endif

View File

@ -53,6 +53,8 @@
/* --- CRC function prototypes --------------------------------------------- */
BEGIN_DECLS
/* TODO */
/**
@ -75,4 +77,6 @@ u32 crc_calculate(u32 data);
*/
u32 crc_calculate_block(u32 *datap, int size);
END_DECLS
#endif

View File

@ -393,6 +393,8 @@ typedef enum {
/* --- Function prototypes ------------------------------------------------- */
BEGIN_DECLS
void dac_enable(data_channel dac_channel);
void dac_disable(data_channel dac_channel);
void dac_buffer_enable(data_channel dac_channel);
@ -409,6 +411,8 @@ void dac_load_data_buffer_single(u32 dac_data, data_align dac_data_format, data_
void dac_load_data_buffer_dual(u32 dac_data1, u32 dac_data2, data_align dac_data_format);
void dac_software_trigger(data_channel dac_channel);
END_DECLS
#endif
/**@}*/

View File

@ -61,10 +61,14 @@ typedef enum trigger_e {
EXTI_TRIGGER_BOTH,
} exti_trigger_type;
BEGIN_DECLS
void exti_set_trigger(u32 extis, exti_trigger_type trig);
void exti_enable_request(u32 extis);
void exti_disable_request(u32 extis);
void exti_reset_request(u32 extis);
void exti_select_source(u32 exti, u32 gpioport);
END_DECLS
#endif

View File

@ -677,6 +677,9 @@ LGPL License Terms @ref lgpl_license
/* --- Function prototypes ------------------------------------------------- */
BEGIN_DECLS
/* TODO */
void adc_enable_analog_watchdog_regular(u32 adc);
void adc_disable_analog_watchdog_regular(u32 adc);
void adc_enable_analog_watchdog_injected(u32 adc);
@ -722,6 +725,8 @@ void adc_set_watchdog_low_threshold(u32 adc, u16 threshold);
void adc_set_regular_sequence(u32 adc, u8 length, u8 channel[]);
void adc_set_injected_sequence(u32 adc, u8 length, u8 channel[]);
END_DECLS
#endif
/**@}*/

View File

@ -36,6 +36,8 @@
#define DESIG_UID_63_32 MMIO32(DESIG_UNIQUE_ID_BASE + 0x04)
#define DESIG_UID_95_64 MMIO32(DESIG_UNIQUE_ID_BASE + 0x08)
BEGIN_DECLS
/**
* Read the onboard flash size
* @return flash size in KB
@ -49,4 +51,6 @@ u16 desig_get_flash_size(void);
*/
void desig_get_unique_id(u32 result[]);
END_DECLS
#endif

View File

@ -346,6 +346,8 @@ LGPL License Terms @ref lgpl_license
/* --- function prototypes ------------------------------------------------- */
BEGIN_DECLS
void dma_channel_reset(u32 dma, u8 channel);
void dma_enable_mem2mem_mode(u32 dma, u8 channel);
void dma_set_priority(u32 dma, u8 channel, u32 prio);
@ -368,6 +370,8 @@ void dma_set_peripheral_address(u32 dma, u8 channel, u32 address);
void dma_set_memory_address(u32 dma, u8 channel, u32 address);
void dma_set_number_of_data(u32 dma, u8 channel, u16 number);
END_DECLS
#endif
/**@}*/

View File

@ -89,6 +89,8 @@
/* --- Function prototypes ------------------------------------------------- */
BEGIN_DECLS
void flash_prefetch_buffer_enable(void);
void flash_prefetch_buffer_disable(void);
void flash_halfcycle_enable(void);
@ -110,4 +112,6 @@ void flash_wait_for_last_operation(void);
void flash_erase_option_bytes(void);
void flash_program_option_bytes(u32 address, u16 data);
END_DECLS
#endif

View File

@ -950,6 +950,8 @@ Line Devices only
/* --- Function prototypes ------------------------------------------------- */
BEGIN_DECLS
void gpio_set_mode(u32 gpioport, u8 mode, u8 cnf, u16 gpios);
void gpio_set(u32 gpioport, u16 gpios);
void gpio_clear(u32 gpioport, u16 gpios);
@ -962,6 +964,8 @@ void gpio_set_eventout(u8 evoutport, u8 evoutpin);
void gpio_primary_remap(u8 swjenable, u32 maps);
void gpio_secondary_remap(u32 maps);
END_DECLS
#endif
/**@}*/

View File

@ -476,6 +476,8 @@ typedef enum {
PLL, HSE, HSI, LSE, LSI
} osc_t;
BEGIN_DECLS
void rcc_osc_ready_int_clear(osc_t osc);
void rcc_osc_ready_int_enable(osc_t osc);
void rcc_osc_ready_int_disable(osc_t osc);
@ -512,6 +514,8 @@ void rcc_clock_setup_in_hse_12mhz_out_72mhz(void);
void rcc_clock_setup_in_hse_16mhz_out_72mhz(void);
void rcc_backupdomain_reset(void);
END_DECLS
#endif
/**@}*/

View File

@ -126,6 +126,8 @@ typedef enum {
RTC_SEC, RTC_ALR, RTC_OW,
} rtcflag_t;
BEGIN_DECLS
void rtc_awake_from_off(osc_t clock_source);
void rtc_enter_config_mode(void);
void rtc_exit_config_mode(void);
@ -144,4 +146,6 @@ u32 rtc_check_flag(rtcflag_t flag_val);
void rtc_awake_from_standby(void);
void rtc_auto_awake(osc_t clock_source, u32 prescale_val);
END_DECLS
#endif

View File

@ -293,10 +293,15 @@
/* BFAR [31:0]: Bus fault address */
/* --- SCB functions ------------------------------------------------------- */
BEGIN_DECLS
void scb_reset_core(void);
void scb_reset_system(void);
void scb_set_priority_grouping(u32 prigroup);
/* TODO: */
END_DECLS
#endif

View File

@ -116,6 +116,8 @@
/* --- Function prototypes ------------------------------------------------- */
BEGIN_DECLS
void flash_dcache_enable(void);
void flash_dcache_disable(void);
void flash_icache_enable(void);
@ -145,4 +147,6 @@ void flash_program_byte(u32 address, u8 data, u32 program_size);
void flash_wait_for_last_operation(void);
void flash_program_option_bytes(u32 data);
END_DECLS
#endif

View File

@ -254,6 +254,8 @@
/* --- Function prototypes ------------------------------------------------- */
BEGIN_DECLS
/*
* Note: The F2 series has a completely new GPIO peripheral with different
* configuration options. Here we implement a different API partly to more
@ -275,4 +277,6 @@ u16 gpio_port_read(u32 gpioport);
void gpio_port_write(u32 gpioport, u16 data);
void gpio_port_config_lock(u32 gpioport, u16 gpios);
END_DECLS
#endif

View File

@ -479,6 +479,8 @@ typedef enum {
PLL, HSE, HSI, LSE, LSI
} osc_t;
BEGIN_DECLS
void rcc_osc_ready_int_clear(osc_t osc);
void rcc_osc_ready_int_enable(osc_t osc);
void rcc_osc_ready_int_disable(osc_t osc);
@ -509,4 +511,6 @@ u32 rcc_get_system_clock_source(int i);
void rcc_clock_setup_hse_3v3(const clock_scale_t *clock);
void rcc_backupdomain_reset(void);
END_DECLS
#endif

View File

@ -293,10 +293,15 @@
/* BFAR [31:0]: Bus fault address */
/* --- SCB functions ------------------------------------------------------- */
BEGIN_DECLS
void scb_reset_core(void);
void scb_reset_system(void);
void scb_set_priority_grouping(u32 prigroup);
/* TODO: */
END_DECLS
#endif

View File

@ -52,6 +52,10 @@
/* --- Function prototypes ------------------------------------------------- */
BEGIN_DECLS
void timer_set_option(u32 timer_peripheral, u32 option);
END_DECLS
#endif

View File

@ -115,6 +115,8 @@
/* --- Function prototypes ------------------------------------------------- */
BEGIN_DECLS
void flash_dcache_enable(void);
void flash_dcache_disable(void);
void flash_icache_enable(void);
@ -144,4 +146,6 @@ void flash_program_byte(u32 address, u8 data, u32 program_size);
void flash_wait_for_last_operation(void);
void flash_program_option_bytes(u32 data);
END_DECLS
#endif

View File

@ -254,6 +254,8 @@
/* --- Function prototypes ------------------------------------------------- */
BEGIN_DECLS
/*
* Note: The F4 series has a completely new GPIO peripheral with different
* configuration options. Here we implement a different API partly to more
@ -275,4 +277,6 @@ u16 gpio_port_read(u32 gpioport);
void gpio_port_write(u32 gpioport, u16 data);
void gpio_port_config_lock(u32 gpioport, u16 gpios);
END_DECLS
#endif

View File

@ -63,6 +63,10 @@ typedef enum {
SCALE2,
} vos_scale_t;
BEGIN_DECLS
void pwr_set_vos_scale(vos_scale_t scale);
END_DECLS
#endif

View File

@ -482,6 +482,8 @@ typedef enum {
PLL, HSE, HSI, LSE, LSI
} osc_t;
BEGIN_DECLS
void rcc_osc_ready_int_clear(osc_t osc);
void rcc_osc_ready_int_enable(osc_t osc);
void rcc_osc_ready_int_disable(osc_t osc);
@ -512,4 +514,6 @@ u32 rcc_get_system_clock_source(int i);
void rcc_clock_setup_hse_3v3(const clock_scale_t *clock);
void rcc_backupdomain_reset(void);
END_DECLS
#endif

View File

@ -293,10 +293,15 @@
/* BFAR [31:0]: Bus fault address */
/* --- SCB functions ------------------------------------------------------- */
BEGIN_DECLS
void scb_reset_core(void);
void scb_reset_system(void);
void scb_set_priority_grouping(u32 prigroup);
/* TODO: */
END_DECLS
#endif

View File

@ -52,6 +52,10 @@
/* --- Function prototypes ------------------------------------------------- */
BEGIN_DECLS
void timer_set_option(u32 timer_peripheral, u32 option);
END_DECLS
#endif

View File

@ -316,6 +316,8 @@
/* --- I2C funtion prototypes----------------------------------------------- */
BEGIN_DECLS
void i2c_reset(u32 i2c);
void i2c_peripheral_enable(u32 i2c);
void i2c_peripheral_disable(u32 i2c);
@ -331,4 +333,6 @@ void i2c_set_trise(u32 i2c, u16 trise);
void i2c_send_7bit_address(u32 i2c, u8 slave, u8 readwrite);
void i2c_send_data(u32 i2c, u8 data);
END_DECLS
#endif

View File

@ -106,12 +106,16 @@ LGPL License Terms @ref lgpl_license
/* --- IWDG function prototypes---------------------------------------------- */
BEGIN_DECLS
void iwdg_start(void);
void iwdg_set_period_ms(u32 period);
bool iwdg_reload_busy(void);
bool iwdg_prescaler_busy(void);
void iwdg_reset(void);
END_DECLS
#endif
/**@}*/

View File

@ -116,6 +116,8 @@ IRQ numbers -3 and -6 to -9 are reserved
/* --- NVIC functions ------------------------------------------------------ */
BEGIN_DECLS
void nvic_enable_irq(u8 irqn);
void nvic_disable_irq(u8 irqn);
u8 nvic_get_pending_irq(u8 irqn);
@ -126,6 +128,8 @@ u8 nvic_get_irq_enabled(u8 irqn);
void nvic_set_priority(u8 irqn, u8 priority);
void nvic_generate_software_interrupt(u16 irqn);
END_DECLS
#endif
/**@}*/

View File

@ -106,6 +106,8 @@ LGPL License Terms @ref lgpl_license
/* --- PWR function prototypes ------------------------------------------- */
BEGIN_DECLS
void pwr_disable_backup_domain_write_protect(void);
void pwr_enable_backup_domain_write_protect(void);
void pwr_enable_power_voltage_detect(u32 pvd_level);
@ -122,6 +124,8 @@ bool pwr_voltage_high(void);
bool pwr_get_standby_flag(void);
bool pwr_get_wakeup_flag(void);
END_DECLS
#endif
/**@}*/

View File

@ -142,7 +142,7 @@
#define SDIO_CMD_WAITRESP_SHIFT 6
/* 00: No response, expect CMDSENT flag */
#define SDIO_CMD_WAITRESP_NO_0 (0x0 << SDIO_CMD_WAITRESP_SHIFT)
/* 01: Short response, expect CMDREND or CCRCFAIL flag
/* 01: Short response, expect CMDREND or CCRCFAIL flag */
#define SDIO_CMD_WAITRESP_SHORT (0x1 << SDIO_CMD_WAITRESP_SHIFT)
/* 10: No response, expect CMDSENT flag */
#define SDIO_CMD_WAITRESP_NO_2 (0x2 << SDIO_CMD_WAITRESP_SHIFT)

View File

@ -297,6 +297,8 @@
/* --- Function prototypes ------------------------------------------------- */
BEGIN_DECLS
void spi_reset(u32 spi_peripheral);
int spi_init_master(u32 spi, u32 br, u32 cpol, u32 cpha, u32 dff, u32 lsbfirst);
void spi_enable(u32 spi);
@ -343,4 +345,6 @@ void spi_disable_tx_dma(u32 spi);
void spi_enable_rx_dma(u32 spi);
void spi_disable_rx_dma(u32 spi);
END_DECLS
#endif

View File

@ -93,6 +93,8 @@ LGPL License Terms @ref lgpl_license
/* --- Function Prototypes ------------------------------------------------- */
BEGIN_DECLS
void systick_set_reload(u32 value);
u32 systick_get_value(void);
void systick_set_clocksource(u8 clocksource);
@ -102,6 +104,8 @@ void systick_counter_enable(void);
void systick_counter_disable(void);
u8 systick_get_countflag(void);
END_DECLS
#endif
/**@}*/

View File

@ -1022,6 +1022,9 @@ enum tim_ic_pol {
};
/* --- TIM function prototypes ------------------------------------------------------- */
BEGIN_DECLS
void timer_reset(u32 timer_peripheral);
void timer_enable_irq(u32 timer_peripheral, u32 irq);
void timer_disable_irq(u32 timer_peripheral, u32 irq);
@ -1101,6 +1104,8 @@ void timer_slave_set_polarity(u32 timer, enum tim_ic_pol pol);
void timer_slave_set_mode(u32 timer, u8 mode);
void timer_slave_set_trigger(u32 timer, u8 trigger);
END_DECLS
#endif
/**@}*/

View File

@ -294,6 +294,8 @@
/* --- Function prototypes ------------------------------------------------- */
BEGIN_DECLS
void usart_set_baudrate(u32 usart, u32 baud);
void usart_set_databits(u32 usart, u32 bits);
void usart_set_stopbits(u32 usart, u32 stopbits);
@ -313,4 +315,6 @@ void usart_disable_rx_dma(u32 usart);
void usart_enable_tx_dma(u32 usart);
void usart_disable_tx_dma(u32 usart);
END_DECLS
#endif

View File

@ -22,6 +22,8 @@
#include <libopencm3/usb/usbstd.h>
BEGIN_DECLS
typedef struct _usbd_driver usbd_driver;
extern const usbd_driver stm32f103_usb_driver;
extern const usbd_driver stm32f107_usb_driver;
@ -73,4 +75,6 @@ extern void usbd_ep_nak_set(u8 addr, u8 nak);
/* Optional */
extern void usbd_cable_connect(u8 on);
END_DECLS
#endif