- folder structure reordered

- unnecessary drivers removed
This commit is contained in:
tkl
2016-07-27 14:47:22 +02:00
parent f5b7f032e1
commit 4eaea0c98b
46 changed files with 60 additions and 1066 deletions

View File

@@ -1,77 +0,0 @@
//! \file stm32_sys_tick.c
//! \author tkl
//! \date Feb 15, 2012
//! \brief Source file of the stm32f10x architecture dependent sys tick timer implementation.
#include <stdint.h>
#include <stddef.h>
#include <stdio.h>
#include "stm32f4xx.h"
#include "stm32_sys_tick.h"
#include "stm32f4xx_isr.h"
struct stm32_sys_tick_obj {
stm32_sys_tick_cb_t sys_tick_cb;
void *sys_tick_cb_param;
};
static struct stm32_sys_tick_obj stm32_sys_tick_obj;
int stm32_sys_tick_open(const void *sys_tick) {
if(sys_tick == NULL)
return -1;
struct stm32_sys_tick *this = (struct stm32_sys_tick *)sys_tick;
uint32_t div = 1000;
switch(*this->tick_time_base) {
case STM32_SYS_TICK_TIME_BASE_US:
div = 1000000;
break;
case STM32_SYS_TICK_TIME_BASE_MS:
div = 1000;
break;
default:
return -1;
}
if(SysTick_Config(SystemCoreClock / div))
return -1;
return 0;
}
int stm32_sys_tick_close(const void *sys_tick)
{
if(sys_tick == NULL)
return -1;
SysTick->CTRL = 0;
return 0;
}
int stm32_sys_tick_set_cb(const void *sys_tick, const void *callback, const void *param)
{
if((sys_tick == NULL) || (callback == NULL))
return -1;
stm32_sys_tick_obj.sys_tick_cb = (stm32_sys_tick_cb_t)callback;
stm32_sys_tick_obj.sys_tick_cb_param = (void*)param;
return 0;
}
void SysTick_Handler(void)
{
enter_isr();
if(stm32_sys_tick_obj.sys_tick_cb != NULL) {
stm32_sys_tick_cb_t cb = stm32_sys_tick_obj.sys_tick_cb;
void *param = stm32_sys_tick_obj.sys_tick_cb_param;
cb(param);
}
exit_isr();
}

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_ */