47 lines
1.5 KiB
C
47 lines
1.5 KiB
C
#ifndef MYTIMER_H
|
||
#define MYTIMER_H
|
||
#include "GPIO.h"
|
||
#include "stm32f10x.h"
|
||
|
||
|
||
typedef struct
|
||
{
|
||
TIM_TypeDef * Timer ; // TIM1 à TIM4
|
||
unsigned short ARR;
|
||
unsigned short PSC;
|
||
}MyTimer_Struct_TypeDef;
|
||
/*
|
||
*****************************************************************************************
|
||
* @brief
|
||
* @param -> Paramètre sous forme d’une structure (son adresse) contenant les
|
||
informations de base
|
||
* @Note -> Fonction à lancer systématiquement avant d’aller plus en détail dans les
|
||
conf plus fines (PWM, codeur inc...)
|
||
*************************************************************************************************
|
||
*/
|
||
void MyTimer_Base_Init (MyTimer_Struct_TypeDef * Timer);
|
||
/*
|
||
*****************************************************************************************
|
||
* @brief
|
||
* @param -> - TIM_TypeDef * Timer : Timer concerne
|
||
- char Prio : de 0 a 15
|
||
* @Note -> La fonction MyTimer_Base_Init doit avoir ete lancee au prealable
|
||
*************************************************************************************************
|
||
*/
|
||
void MyTimer_ActiveIT (TIM_TypeDef * Timer, char Prio, void (*IT_function)(void));
|
||
|
||
|
||
#define MyTimer_Base_Start(Timer) (Timer->CR1 |= 0x01)
|
||
#define MyTimer_Base_Stop(Timer) (Timer->CR1 &= ~0x01)
|
||
#define PWM_output 0x00
|
||
#define PWM_inputTI1 0x01
|
||
#define PWM_inputTI2 0x10
|
||
#define PWM_inputTRC 0x11
|
||
|
||
void MyPWM_init ( TIM_TypeDef * Timer,char Channel);
|
||
void MyPWM_Duty (TIM_TypeDef * Timer,char Channel, unsigned short CRR );
|
||
void init_encoder_timer(void (*IT_function)(void));
|
||
void Reset_degree (void);
|
||
int Read_CNT (void);
|
||
|
||
#endif
|