gpio toggle works

This commit is contained in:
tkl
2016-08-15 22:25:35 +02:00
parent 067dd1d3e5
commit 073f5093dd
16 changed files with 99 additions and 593 deletions

View File

@@ -1,49 +0,0 @@
//! \file stm32_sys_tick.h
//! \author tkl
//! \date Feb 15, 2012
//! \brief Header file of the stm32f10x architecture dependent sys tick timer implementation.
#ifndef STM32_SYS_TICK_H_
#define STM32_SYS_TICK_H_
#include "timer.h"
typedef void* (*stm32_sys_tick_cb_t)(void*); //!< callback for the external interrupt
//! \brief Type of sys tick base time.
enum stm32_sys_tick_time_base {
STM32_SYS_TICK_TIME_BASE_NONE = 0, //!< Not init
STM32_SYS_TICK_TIME_BASE_US, //!< Tick time = 1 us.
STM32_SYS_TICK_TIME_BASE_MS //!< Tick time = 1 ms.
};
//! \brief The sys tick device.
struct stm32_sys_tick {
const enum stm32_sys_tick_time_base *tick_time_base; //!< time base for the system tick
stm32_sys_tick_cb_t sys_tick_cb; //!< callback for the sys tick interrupt
void *sys_tick_cb_param; //!< parameter for the callback
};
//! \brief Open a sys tick timer.
//! \param sys_tick The sys tick to open. Must be of type const stm32_sys_tick_t*.
//! \return -1 in error case.
int stm32_sys_tick_open(const void *sys_tick);
//! \brief Close a sys tick timer.
//! \param sys_tick The sys tick to close. Must be of type const stm32_sys_tick_t*.
//! \return -1 in error case.
int stm32_sys_tick_close(const void *sys_tick);
//! \brief Set the call back for a sys tick timer.
//! \param sys_tick The sys tick to open. Mus be of type const stm32_sys_tick_t*.
//! \param callback The function pointer of the call back function.
//! \param param The parameter for the call back function.
//! \return -1 in error case.
int stm32_sys_tick_set_cb(const void *sys_tick, const void *callback, const void *param);
static const struct timer_fp timer_fp = {
stm32_sys_tick_open,
stm32_sys_tick_close,
stm32_sys_tick_set_cb
};
#endif /* STM32_SYS_TICK_H_ */

View File

@@ -12,8 +12,6 @@ typedef void* (*gpio_ext_it_cb_t)(void*);
struct stm32f4_gpio {
GPIO_TypeDef *port; //!< Gpio port
const GPIO_InitTypeDef *pin; //!< Gpio pin
gpio_ext_it_cb_t ext_it_cb; //!< Gpio ext it callback (could be NULL)
void *param; //!< Parameter for the callback
};
//! \brief Open a gpio.

View File

@@ -1,40 +0,0 @@
/*
* stm32f4_pwm.h
*
* Created on: Aug 9, 2016
* Author: tkl
*/
#ifndef SOURCE_FIRMWARE_ARCH_STM32F4XX_DRIVER_INCLUDE_STM32F4_PWM_H_
#define SOURCE_FIRMWARE_ARCH_STM32F4XX_DRIVER_INCLUDE_STM32F4_PWM_H_
enum stm32f4_pwm_channel {
channel_1 = 1,
channel_2,
channel_3,
channel_4
};
struct stm32f4_pwm {
TIM_TypeDef *timer;
const TIM_TimeBaseInitTypeDef *timer_cfg;
const TIM_OCInitTypeDef *output_compare_cfg;
const TIM_BDTRInitTypeDef *bdtr_cfg;
GPIO_TypeDef *port;
uint8_t pin_src;
const GPIO_InitTypeDef *port_cfg;
enum stm32f4_pwm_channel channel;
};
int stm32f4_pwm_open(const void *pwm);
int stm32f4_pwm_close(const void *pwm);
int stm32f4_pwm_set_duty_cycle(const void *pwm, unsigned int duty_cycle_percent);
static const struct pwm_fp stm32f4_pwm_fp = {
.open = stm32f4_pwm_open,
.close = stm32f4_pwm_close,
.set_duty_cycle = stm32f4_pwm_set_duty_cycle,
};
#endif /* SOURCE_FIRMWARE_ARCH_STM32F4XX_DRIVER_INCLUDE_STM32F4_PWM_H_ */

View File

@@ -1,65 +0,0 @@
/*
* stm32_uart.h
*
* Created on: Jul 24, 2016
* Author: tkl
*/
#ifndef SOURCE_FIRMWARE_ARCH_STM32F4XX_DRIVER_UART_STM32_UART_H_
#define SOURCE_FIRMWARE_ARCH_STM32F4XX_DRIVER_UART_STM32_UART_H_
#include "driver.h"
#include "uart.h"
//! \brief Stm32f4 uart device.
struct stm32f4_uart {
const GPIO_InitTypeDef *gpio_init;
GPIO_TypeDef *gpio_port;
uint8_t pin_src_rx;
uint8_t pin_src_tx;
const USART_InitTypeDef *usart_init;
USART_TypeDef *usart_port;
uint16_t usart_it_select;
const NVIC_InitTypeDef *nvic_init;
};
//! \brief Open an uart device.
//! \param this The uart to open.
//! \retval -1 in error case.
int stm32f4_uart_open(const void *this);
//! \brief Close an uart device.
//! \param this The uart to close.
//! \retval -1 in error case.
int stm32f4_uart_close(const void *this);
//! \brief Read from an uart device.
//! \param this The uart to read from.
//! \param buffer The buffer to read to.
//! \param len The length of the buffer.
//! \retval -1 in error case, otherwise number of read characters.
int stm32f4_uart_read(const void *this, char *buffer, int len);
//! \brief Write to an uart device.
//! \param this The uart to write to.
//! \param buffer The buffer to write.
//! \param len The number of characters to write.
//! \retval -1 in error case, otherwise number of written characters.
int stm32f4_uart_write(const void *this, const char *buffer, int len);
//! \brief Set a callback for interrupt handling of the uart.
//! \param this The uart.
//! \param callback The callback to execute in interrupt case.
//! \param param The argument for the callback.
//! \retval -1 in error case.
int stm32f4_uart_set_cb(const void *this, const void *callback, const void *param);
static const struct uart_fp stm32f4_uart_fp = {
stm32f4_uart_open,
stm32f4_uart_close,
stm32f4_uart_read,
stm32f4_uart_write,
stm32f4_uart_set_cb
};
#endif /* SOURCE_FIRMWARE_ARCH_STM32F4XX_DRIVER_UART_STM32_UART_H_ */