Remplacement des fichiers
This commit is contained in:
parent
137e61c2ca
commit
ee0077b722
60 changed files with 10789 additions and 0 deletions
89
ProjetInitial/Application/principal.c
Executable file
89
ProjetInitial/Application/principal.c
Executable file
|
|
@ -0,0 +1,89 @@
|
|||
#include <stm32f10x.h>
|
||||
#include <stdio.h> // Pour afficher
|
||||
#include "Horloge.h"
|
||||
#include "Accelerometre.h"
|
||||
#include "Girouette.h"
|
||||
#include "Servo.h"
|
||||
#include "MyUart.h"
|
||||
#include "Plateau.h"
|
||||
#include "I2C.h"
|
||||
#include "RTC.h"
|
||||
|
||||
|
||||
void pilotage(int commande) {
|
||||
Update_Motor_PWM(commande,TIM3,3);
|
||||
};
|
||||
|
||||
|
||||
//#define ANGLE_LIMITE 0x0E38
|
||||
|
||||
//Variables
|
||||
int angleVentVar;
|
||||
int angleVoileVar;
|
||||
|
||||
uint16_t * Melding;
|
||||
volatile uint16_t X;
|
||||
volatile uint16_t Y;
|
||||
volatile uint16_t Z;
|
||||
volatile uint32_t moy;
|
||||
//volatile uint16_t Angle_lim = 0x1500;
|
||||
|
||||
//volatile uint16_t Angle_lim = 0x1E20 - 60*ANGLE;
|
||||
|
||||
|
||||
int main (void) {
|
||||
// ---- Setup ------
|
||||
// Servo.c
|
||||
initServo(TIM4, 3);
|
||||
// Giroutte.c
|
||||
configEncoder(TIM2);
|
||||
|
||||
/*
|
||||
//Test de lecture ADC
|
||||
My_USART_Config(USART1, 7500);
|
||||
initADC();
|
||||
while(1){
|
||||
sendinfoADC();
|
||||
}
|
||||
*/
|
||||
|
||||
// Init moyenne glissante
|
||||
int i = 0;
|
||||
uint32_t moyenne[LONGUEUR_MOY];
|
||||
for (int p = 0; p<LONGUEUR_MOY; p++){moyenne[p]=0xFFFF;}
|
||||
|
||||
//init Uart
|
||||
My_USART_Config(USART1, 7500); //call with baudrate which is one over this value times clock frequency
|
||||
USART_IT_Receive_Enable(USART1);
|
||||
Init_IT_Receive(pilotage);
|
||||
USART_Send_String(USART1,"bonjour bateau\r\n");
|
||||
|
||||
|
||||
|
||||
RCC->APB2ENR |= RCC_APB2ENR_IOPBEN;
|
||||
// Init lacheurVoile
|
||||
initAccelo();
|
||||
initServo(TIM4, 3);
|
||||
|
||||
// Trouver l'index
|
||||
LocaliserZero();
|
||||
int sum;
|
||||
|
||||
while(1){
|
||||
// Girouette
|
||||
angleVentVar = angleVent(TIM2); // Récupérer l'angle de girouette
|
||||
angleVoileVar = vent2voile(angleVentVar); // Transformer l'angle de girouette au l'angle des voiles souhaités
|
||||
Servo_Moteur(angleVoileVar, TIM4, 3); // Faire bouger le moteur servo
|
||||
|
||||
// Acceleromètre
|
||||
moyenne[i] = RecupAccelo()[2]; // Récuperation et ajout de la valeur plus récente dans le tableau dans la position i
|
||||
i++; if (i >= LONGUEUR_MOY) {i = 0;} // Géstion de la position i dans le tableau pour la moyenne glissante
|
||||
sum = 0; for (int j = 0; j < LONGUEUR_MOY; j++){sum += moyenne[j];} moy = sum / LONGUEUR_MOY; // Calcul de la moyenne glissante
|
||||
LacheVoile(ANGLE_LIMITE, (uint16_t) moy); // Lache la voile si le bateau dépasse l'angle limite
|
||||
|
||||
LacheVoile(50, (uint16_t)moy);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
BIN
ProjetInitial/Lib_Com_Periph_2022.lib
Executable file
BIN
ProjetInitial/Lib_Com_Periph_2022.lib
Executable file
Binary file not shown.
8
ProjetInitial/Pilotes/Include/ADC.h
Executable file
8
ProjetInitial/Pilotes/Include/ADC.h
Executable file
|
|
@ -0,0 +1,8 @@
|
|||
#include <stm32f10x.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define GPIO_ANALOG_INPUT 0
|
||||
|
||||
void initADC();
|
||||
int recupADC(void);
|
||||
void sendinfoADC();
|
||||
19
ProjetInitial/Pilotes/Include/DriverGPIO.h
Executable file
19
ProjetInitial/Pilotes/Include/DriverGPIO.h
Executable file
|
|
@ -0,0 +1,19 @@
|
|||
#ifndef DRIVERGPIO_H_
|
||||
#define DRIVERGPIO_H_
|
||||
#include "stm32f10x.h"
|
||||
#define In_Floating 0x4
|
||||
#define In_PullDown 0x8
|
||||
#define In_PullUp 0x8
|
||||
#define In_Analog 0x0
|
||||
#define Out_Ppull 0x3
|
||||
#define Out_OD 0x7
|
||||
#define AltOut_Ppull 0xB
|
||||
#define AltOut_OD 0xF
|
||||
extern void MyGPIO_Init(GPIO_TypeDef * GPIO, char pin, char conf );
|
||||
extern int MyGPIO_Read(GPIO_TypeDef * GPIO, char GPIO_Pin); // renvoie 0 ou autre chose different de 0
|
||||
extern void MyGPIO_Set(GPIO_TypeDef * GPIO, char GPIO_Pin);
|
||||
extern void MyGPIO_Reset(GPIO_TypeDef * GPIO, char GPIO_Pin);
|
||||
extern void MyGPIO_Toggle(GPIO_TypeDef * GPIO, char GPIO_Pin);
|
||||
void MYGPIO_PinOff (GPIO_TypeDef *GPIO , char GPIO_Pin);
|
||||
void MYGPIO_PinOn (GPIO_TypeDef *GPIO , char GPIO_Pin);
|
||||
#endif
|
||||
16
ProjetInitial/Pilotes/Include/Horloge.h
Executable file
16
ProjetInitial/Pilotes/Include/Horloge.h
Executable file
|
|
@ -0,0 +1,16 @@
|
|||
#include <stm32f10x.h>
|
||||
#define PSC_VAL 624
|
||||
#define ARR_VAL 0xE0FF
|
||||
|
||||
//DUTY CYCLE
|
||||
#define DUTYC 70 //Chiffre entre 0 et 100, où 100 est 100% duty cycle
|
||||
//#define POWERMODE 1 // 1 vaut powermode 1, 0 vaut powermode 2 (Powermode pour le config de dutycycle)
|
||||
//Powermode 1 reste sur la bonne polarité: cad. si DUTY_CYCLE vaut 60 alors le signal reste HIGH pour 60% du periode, inverse pour pwmd2
|
||||
//Timer
|
||||
void Timer_Init(TIM_TypeDef *Timer, unsigned short Autoreload, unsigned short Prescaler);
|
||||
void MyTimer_ActiveIT(TIM_TypeDef * Timer, char Prio, void(*Interrupt_fonc)(void));
|
||||
void TIM2_IRQHandler(void);
|
||||
|
||||
//PWM
|
||||
void MyTimer_PWM(TIM_TypeDef * Timer , int Channel);
|
||||
int Set_DutyCycle_PWM(TIM_TypeDef *Timer, int Channel, int DutyC);
|
||||
2
ProjetInitial/Pilotes/Include/I2C.h
Executable file
2
ProjetInitial/Pilotes/Include/I2C.h
Executable file
|
|
@ -0,0 +1,2 @@
|
|||
#include <stm32f10x.h>
|
||||
void initI2C();
|
||||
38
ProjetInitial/Pilotes/Include/MYGPIO.h
Executable file
38
ProjetInitial/Pilotes/Include/MYGPIO.h
Executable file
|
|
@ -0,0 +1,38 @@
|
|||
//Definitions
|
||||
|
||||
//INTERNE
|
||||
#define LED_PIN_INTERNE (5) // 5 pour le LED de Arduino
|
||||
#define BUTTON_GPIO_INTERNE (GPIOA) //GPIOA pour l'Arduion
|
||||
#define LED_GPIO_INTERNE (GPIOA) //GPIOA pour Arduino
|
||||
#define BUTTON_PIN_INTERNE (13) //13 pour Arduino
|
||||
|
||||
//EXTERNE
|
||||
#define LED_PIN_EXTERNE (8) // 8 pour la porte PB8
|
||||
#define BUTTON_GPIO_EXTERNE (GPIOB) //GPIOB pour externe
|
||||
#define LED_GPIO_EXTERNE (GPIOB) //GPIOB pour Externe
|
||||
#define BUTTON_PIN_EXTERNE (9) //9 pour bouton poussoir
|
||||
|
||||
//STATIQUES
|
||||
#define GPIO_OUTPUT_PPULL_MODE (2) //Mis en GP output 2MHz en mode PP
|
||||
#define GPIO_INPUT_PUPD_MODE (8) //Pour mettre à Pull up/down
|
||||
#define GPIO_INPUT_FLOATING_MODE (4)
|
||||
|
||||
//si on est sur l'arduino ou sur le led externe
|
||||
#define INTERNE 1 // 1 c'est vrai, 0 faux
|
||||
|
||||
//FONCTIONS
|
||||
void initGPIO_Interne(void);
|
||||
int boutonAppuye_Interne(void);
|
||||
void allumerDEL_Interne(void);
|
||||
void eteindreDEL_Interne(void);
|
||||
void commuterDEL_Interne(void);
|
||||
void allume_bit_Interne(void);
|
||||
|
||||
void initGPIO_Externe(void);
|
||||
int boutonAppuye_Externe(void);
|
||||
void allumerDEL_Externe(void);
|
||||
void eteindreDEL_Externe(void);
|
||||
void commuterDEL_Externe(void);
|
||||
void allume_bit_Externe(void);
|
||||
|
||||
|
||||
229
ProjetInitial/Pilotes/Include/MyI2C.h
Executable file
229
ProjetInitial/Pilotes/Include/MyI2C.h
Executable file
|
|
@ -0,0 +1,229 @@
|
|||
#ifndef _I2C_
|
||||
#define _I2C_
|
||||
|
||||
#include "stm32f10x.h"
|
||||
|
||||
/*************************************************************************************
|
||||
===================== By Periph team INSA GEI 2022 ===========================
|
||||
*************************************************************************************/
|
||||
|
||||
/*
|
||||
*************************************************************************************
|
||||
===================== I2C les IO STM32F103 =================================
|
||||
*************************************************************************************
|
||||
|
||||
Les IO sont pris en charge par la lib, pas besoin de faire les configurations Alt OD.
|
||||
|
||||
**I2C1**
|
||||
SCL PB6
|
||||
SDA PB7
|
||||
|
||||
**I2C2**
|
||||
SCL PB10
|
||||
SDA PB11
|
||||
|
||||
|
||||
*************************************************************************************
|
||||
==================== Fondamentaux I2C ==========================================
|
||||
*************************************************************************************
|
||||
- Bus synchrone Low speed (<100kHz) ou high speed (=400kHz), Ici Low speed 100kHz.
|
||||
- Transfert octet par octet, poids fort en premier, avec aquittement pour chaque octet
|
||||
- Deux lignes SDA et SCL (horloge) en open drain, repos '1'
|
||||
- bit "normal" = SDA stable lors du pulse SCL (ie durant l'état haut de SCL, SDA est stable)
|
||||
- bit Start/Stop/Restart = SDA non stable lorsque SCL vaut '1' (violation règle précédente)
|
||||
* Start : front descendant de SDA lorsque SCL vaut '1'
|
||||
* Stop : front montant de SDA lorsque SCL = '1'
|
||||
* Restart = Start en cours de trame (typiquement pour changer Write/read).
|
||||
- uC en Mode Master uniquement (c'est notre choix) : c'est le uC qui est maître de l'horloge SCL.
|
||||
- Le Slave a une @ 7 bits. On ajoute un bit LSB qui est /WR (donc 0 pour écriture, 1 pour lecture)
|
||||
- Une adresse s'écrit donc |a6 a5 a4 a3 a2 a1 a0 /WR| ce qui donne 8 bits. Elle indique une future
|
||||
lecture ou écriture.
|
||||
On parle d'@ 7 bits en regroupant |a6 a5 a4 a3 a2 a1 a0|
|
||||
On parle d'@ 8 bits en regroupant |a6 a5 a4 a3 a2 a1 a0 /WR| (donc une @ écriture, une @ lecture)
|
||||
NB : préférer le concept @7bits...c'est plus clair.
|
||||
|
||||
- On peut lire ou écrire une ou plusieurs données à la suite. C'est lors de l'envoie de l'adresse Slave
|
||||
par le Master que le sens à venir pour les datas est indiqué.
|
||||
- En écriture,
|
||||
* les Ack sont faits par le slave après chaque octet envoyé par le master (Ack = mise à 0 le bit 9).
|
||||
- En lecture,
|
||||
* dès que le l@ slave est transmise (/RW = 1), et le Ack réalisé, le slave positionne le bit 7
|
||||
du prochain octet à lire sur SDA par anticipation ,
|
||||
* le master enchaîne ses pulses (9), lors du pulse 9 (le dernier) c'est le master qui acquite.
|
||||
* Après chaque acquitement, le Slave amorce le prochain octet en positionnant son bit 7 sur SDA
|
||||
* Après le dernier octet, le Master génère un stop.
|
||||
* Pour pouvoir générer le stop, le Master doit piloter SDA, or ce n'est pas possible puisque
|
||||
le Slave positionne le futur bit 7 ... Pour régler ce problème :
|
||||
lors du dernier transfert, le Master N'acquitte PAS (NACK). Ainsi le Slave ne
|
||||
propose plus le bit 7 du prochain octet sur SDA et libère SDA. Le Master peut alors clôturer la
|
||||
communication avec un Stop.
|
||||
|
||||
|
||||
|
||||
|
||||
======= Echange typique avec un Slave ================================================================
|
||||
- Une lecture ou écriture se fait vers un Slave et à partir d'une adresse mémoire donnée (pointeur interne).
|
||||
Ce pointeur est automatiquement incrémenté dans le slave lors des accès écriture ou lecture.
|
||||
|
||||
- Ecriture de N octets , trame complète (@ = adresse slave, pt = valeur de chargement du pointeur interne)
|
||||
|Start Cond |@6|@5|@4|@3|@2|@1|@0| Wr =0 |Slave ACK|
|
||||
|pt7|pt6|pt5|pt4|pt3|pt2|pt1|pt0|Slave ACK|
|
||||
|d7|d6|d5|d4|d3|d2|d1|d0|Slave ACK| (data 1)
|
||||
.....
|
||||
|d7|d6|d5|d4|d3|d2|d1|d0|Salve ACK|Stop Cond| (data N)
|
||||
|
||||
- Lecture de N octets à partir d'une adresse de pointeur donnée
|
||||
|Start Cond |@6|@5|@4|@3|@2|@1|@0| Wr =0 |Slave ACK|
|
||||
|pt7|pt6|pt5|pt4|pt3|pt2|pt1|pt0|Slave ACK|
|
||||
|ReStart Cond |@6|@5|@4|@3|@2|@1|@0| Wr =1 |Slave ACK| (NB: restart nécessaire pour changer écriture / lecture)
|
||||
|d7|d6|d5|d4|d3|d2|d1|d0|Master ACK| (data 1)
|
||||
.....
|
||||
|d7|d6|d5|d4|d3|d2|d1|d0|Master ACK| (data N-1)
|
||||
|d7|d6|d5|d4|d3|d2|d1|d0|Master NACK|Stop Cond| (data N)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
*************************************************************************************
|
||||
==================== La lib I2C ==========================================
|
||||
*************************************************************************************
|
||||
|
||||
3 fonctions essentielles :
|
||||
MyI2C_Init
|
||||
MyI2C_PutString
|
||||
MyI2C_GetString
|
||||
|
||||
1 fonction spéciale : MyI2C_Get_Error
|
||||
|
||||
Les fonctions Put/Get string fonctionnent sur le principe classique décrit précédemment
|
||||
(Slave@, Pter @, Data...).
|
||||
La fonction init prend parmi ses paramètres le nom d'une fct callback d'erreur.
|
||||
En fait, le driver gère en IT les erreurs possibles I2C. La fonction MyI2C_Get_Error permet de
|
||||
recevoir un code erreur.
|
||||
Il est conseillé d'utiliser ce callback. Si on tombe dedans, c'est qu'une erreur s'est produite.
|
||||
Si le code erreur est "inconnu", souvent c'est qu'il y a un soucis à l'adressage slave:
|
||||
Vérifier alors la connectique physique SDA/SCL ainsi que l'alimentation du slave ou tout simplement
|
||||
l'@ slave !
|
||||
|
||||
|
||||
==========================================================================================*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*=========================================================================================
|
||||
GESTION ERREURS
|
||||
========================================================================================= */
|
||||
typedef enum
|
||||
{
|
||||
OK,
|
||||
BusError, //
|
||||
AckFail, // Pas,d'ack
|
||||
TimeOut, // SCL est resté plus de 25ms à l'état bas
|
||||
UnknownError // IT erreur déclenchée mais pas de flag explicite ...
|
||||
} MyI2C_Err_Enum;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Retourne les erreurs I2C
|
||||
* @param I2Cx: where x can be 1 or 2 to select the I2C peripheral.
|
||||
* @retval Type d'erreur rencontrée , voir MyI2C_Err_Enum
|
||||
*/
|
||||
|
||||
MyI2C_Err_Enum MyI2C_Get_Error(I2C_TypeDef * I2Cx);
|
||||
|
||||
|
||||
|
||||
/*=========================================================================================
|
||||
INITIALISATION I2C
|
||||
========================================================================================= */
|
||||
|
||||
|
||||
/**
|
||||
* @brief Initialise l'interface I2C (1 ou 2)
|
||||
* @param I2Cx: where x can be 1 or 2 to select the I2C peripheral.
|
||||
* @param char IT_Prio_I2CErr 0 à 15 (utilisé en cas d'erreur, IT courte et non bloquante
|
||||
* @param *ITErr_function : callback à utiliser pour sortir d'un plantage transmission
|
||||
* @retval None
|
||||
* @Example MyI2C_Init(I2C1, 2,My_CallbackErr);
|
||||
|
||||
|
||||
|
||||
*/
|
||||
void MyI2C_Init(I2C_TypeDef * I2Cx, char IT_Prio_I2CErr, void (*ITErr_function) (void));
|
||||
|
||||
|
||||
|
||||
/*=========================================================================================
|
||||
EMISSION I2C : PutString
|
||||
========================================================================================= */
|
||||
|
||||
|
||||
// Structure de données pour l'émission ou la réception I2C :
|
||||
typedef struct
|
||||
{
|
||||
char SlaveAdress7bits; // l'adresse I2C du slave device
|
||||
char * Ptr_Data; // l'adresse du début de tableau char à recevoir/émettre (tableau en RAM uC)
|
||||
char Nb_Data; // le nbre d'octets à envoyer / recevoir
|
||||
}
|
||||
MyI2C_RecSendData_Typedef;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief|Start Cond |@6|@5|@4|@3|@2|@1|@0| Wr =0 |Slave ACK|
|
||||
|pt7|pt6|pt5|pt4|pt3|pt2|pt1|pt0|Slave ACK|
|
||||
|d7|d6|d5|d4|d3|d2|d1|d0|Slave ACK| (data 1)
|
||||
.....
|
||||
|d7|d6|d5|d4|d3|d2|d1|d0|Salve ACK|Stop Cond| (data N)
|
||||
|
||||
* @param I2Cx: where x can be 1 or 2 to select the I2C peripheral.
|
||||
* @param PteurAdress = adresse de démarrage écriture à l'interieur du slave I2C
|
||||
* @param DataToSend, adresse de la structure qui contient les informations à transmettre
|
||||
voir définition MyI2C_RecSendData_Typedef
|
||||
* @retval None
|
||||
* @Example MyI2C_PutString(I2C1,0xAA, &MyI2C_SendTimeData);
|
||||
* Ecrit dans le slave câblé sur I2C1 à partir de l'@ mémoire interne Slave 0xAA
|
||||
|
||||
*/
|
||||
void MyI2C_PutString(I2C_TypeDef * I2Cx, char PteurAdress, MyI2C_RecSendData_Typedef * DataToSend);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*=========================================================================================
|
||||
Réception I2C : GetString
|
||||
========================================================================================= */
|
||||
|
||||
/**
|
||||
* @brief |Start Cond |@6|@5|@4|@3|@2|@1|@0| Wr =0 |Slave ACK|
|
||||
|pt7|pt6|pt5|pt4|pt3|pt2|pt1|pt0|Slave ACK|
|
||||
|ReStart Cond |@6|@5|@4|@3|@2|@1|@0| Wr =1 |Slave ACK|
|
||||
|d7|d6|d5|d4|d3|d2|d1|d0|Master ACK| (data 1)
|
||||
.....
|
||||
|d7|d6|d5|d4|d3|d2|d1|d0|Master NACK|Stop Cond| (data N)
|
||||
|
||||
* @param I2Cx: where x can be 1 or 2 to select the I2C peripheral.
|
||||
* @param PteurAdress = adresse de démarrage lecture à l'interieur du slave I2C
|
||||
* @param DataToSend, adresse de la structure qui contient les informations nécessaires à la
|
||||
réception des données voir définition MyI2C_RecSendData_Typedef
|
||||
* @retval None
|
||||
* @Example MyI2C_GetString(I2C1,0xAA, &MyI2C_RecevievedTimeData);
|
||||
Lit dans le slave câblé sur I2C1 à partir de l'@ mémoire interne Slave 0xAA
|
||||
*/
|
||||
void MyI2C_GetString(I2C_TypeDef * I2Cx, char PteurAdress, MyI2C_RecSendData_Typedef * DataToReceive);
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
129
ProjetInitial/Pilotes/Include/MySPI.h
Executable file
129
ProjetInitial/Pilotes/Include/MySPI.h
Executable file
|
|
@ -0,0 +1,129 @@
|
|||
|
||||
#ifndef INC_MYSPI_H_
|
||||
#define INC_MYSPI_H_
|
||||
|
||||
#include "stm32f10x.h"
|
||||
|
||||
/*************************************************************************************
|
||||
===================== By Periph team INSA GEI 2022 ===========================
|
||||
*************************************************************************************/
|
||||
|
||||
/*
|
||||
*************************************************************************************
|
||||
===================== I2C les IO STM32F103 =================================
|
||||
*************************************************************************************
|
||||
Les IO sont pris en charge par la lib, pas besoin de faire les configurations
|
||||
|
||||
|
||||
Sur la Nucléo , le SPI1 est perturbé par la LED2 (PA5), mais doit pouvoir subir les front SCK qd même (LED clignote vite..)
|
||||
le SPI2 n'est pas utilisable car pin non connectées par défaut (sauf à modifier les SB). En fait la Nucléo fait un choix entre SPI1
|
||||
et SPI2 par soudage jumper (SB).
|
||||
|
||||
-> Utiliser SPI1 avec la carte Nucléo
|
||||
|
||||
* **IO SPI 1**
|
||||
SPI1_NSS PA4
|
||||
SPI1_SCK PA5
|
||||
SPI1_MISO PA6
|
||||
SPI1_MOSI PA7
|
||||
|
||||
**IO SPI 2**
|
||||
SPI2_NSS PB12
|
||||
SPI2_SCK PB13
|
||||
SPI2_MISO PB14
|
||||
SPI2_MOSI PB15
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
*************************************************************************************
|
||||
==================== Fondamentaux SPI ==========================================
|
||||
*************************************************************************************
|
||||
- Bus Synchrone, 4 fils (même si on peut l'utiliser en 3 fils)
|
||||
- Transfert à l'octet
|
||||
- Protocole entre un Master (contrôle SCK) et un Slave
|
||||
- SCK permet de synchroniser les bits de chaque octet. Il se configure par :
|
||||
* son niveau de repos : ici niveau '1'
|
||||
* le front actif de synchronisation pour chaque bit : ici front montant (front up durant bit stable)
|
||||
- /CS ou /NSS active le slave sur l'état bas
|
||||
- MOSI : Master Out Slave In (donc data circulant du Master vers le Slave, donc écriture dans le Slave)
|
||||
- MISO : Master In Slave Out (donc data circulant du Slave vers le Master, donc lecture du Slave)
|
||||
|
||||
Bien que la lib propose une fonction d'écriture et de lecture :
|
||||
* une écriture s'accompagne obligatoirement d'une lecture (bidon)
|
||||
* une lecture s'accompagne obligatoirement d'une écriture (bidon)
|
||||
La gestion /CS = /NSS se fait "à la main". On peut alors lire toute une série d'octets
|
||||
en laissant /CS à l'état bas pendant toute la durée de circulation des octets.
|
||||
|
||||
|
||||
*************************************************************************************
|
||||
==================== La lib SPI ==========================================
|
||||
*************************************************************************************
|
||||
|
||||
fonctions essentielles :
|
||||
|
||||
MySPI_Init
|
||||
MySPI_Send
|
||||
MySPI_Read
|
||||
MySPI_Set_NSS
|
||||
MySPI_Clear_NSS
|
||||
|
||||
|
||||
==========================================================================================*/
|
||||
|
||||
|
||||
|
||||
|
||||
/*=========================================================================================
|
||||
INITIALISATION SPI
|
||||
========================================================================================= */
|
||||
|
||||
/**
|
||||
* @brief Configure le SPI spécifié : FSCK = 281kHz, Repos SCK = '1', Front actif = up
|
||||
Gestion /CS logicielle à part, configure les 4 IO
|
||||
- SCK, MOSI : Out Alt push pull
|
||||
- MISO : floating input
|
||||
- /NSS (/CS) : Out push pull
|
||||
* @param SPI_TypeDef * SPI : SPI1 ou SPI2
|
||||
*/
|
||||
void MySPI_Init(SPI_TypeDef * SPI);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Envoie un octet (/CS non géré, à faire logiciellement)
|
||||
Plus en détail, émission de l'octet souhaité sur MOSI
|
||||
Lecture en même temps d'un octet poubelle sur MISO (non exploité)
|
||||
* @param : char ByteToSend : l'octet à envoyer
|
||||
*/
|
||||
void MySPI_Send(char ByteToSend);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Reçoit un octet (/CS non géré, à faire logiciellement)
|
||||
Plus en détail, émission d'un octet bidon sur MOSI (0x00)
|
||||
pour élaborer les 8 fronts sur SCK et donc piloter le slave en lecture
|
||||
qui répond sur MISO
|
||||
* @param : none
|
||||
* @retval : l'octet lu.
|
||||
*/
|
||||
char MySPI_Read(void);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Positionne /CS = /NSS à '1'. A utiliser pour borner les octets à transmettre/recevoir
|
||||
* @param : none
|
||||
*/
|
||||
void MySPI_Set_NSS(void);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Positionne /CS = /NSS à '0'. A utiliser pour borner les octets à transmettre/recevoir
|
||||
* @param :none
|
||||
*/
|
||||
void MySPI_Clear_NSS(void);
|
||||
|
||||
#endif
|
||||
8
ProjetInitial/Pilotes/Include/MyUart.h
Executable file
8
ProjetInitial/Pilotes/Include/MyUart.h
Executable file
|
|
@ -0,0 +1,8 @@
|
|||
#include "stm32f10x.h"
|
||||
|
||||
|
||||
void My_USART_Config(USART_TypeDef* , uint32_t );
|
||||
void USART_Send_Char(USART_TypeDef* , char );
|
||||
void USART_Send_String(USART_TypeDef*, char*);
|
||||
void USART_IT_Receive_Enable(USART_TypeDef*);
|
||||
void Init_IT_Receive(void (*Receive_IT_function) (int));
|
||||
10
ProjetInitial/Pilotes/Include/PWM.h
Executable file
10
ProjetInitial/Pilotes/Include/PWM.h
Executable file
|
|
@ -0,0 +1,10 @@
|
|||
#ifndef PWM_H_
|
||||
#define PWM_H_
|
||||
#include "stm32f10x.h"
|
||||
//Variables
|
||||
#define POWERMODE 2 // 1 vaut powermode 1, 0 vaut powermode 2 (Powermode pour le config de dutycycle)
|
||||
// Config
|
||||
extern void MyTimer_PWM(TIM_TypeDef * Timer , int Channel);
|
||||
extern int Set_DutyCycle_PWM(TIM_TypeDef *Timer, int Channel, int DutyC);
|
||||
int Set_DutyCycle_PWM_Plateau(TIM_TypeDef *Timer, int Channel, int DutyC);
|
||||
#endif
|
||||
4
ProjetInitial/Pilotes/Include/Plateau.h
Executable file
4
ProjetInitial/Pilotes/Include/Plateau.h
Executable file
|
|
@ -0,0 +1,4 @@
|
|||
#include "stm32f10x.h"
|
||||
|
||||
void initPlato(TIM_TypeDef * Timer, int Channel);
|
||||
void Update_Motor_PWM(int Consigne, TIM_TypeDef * Timer, int Channel);
|
||||
8
ProjetInitial/Pilotes/Include/RTC.h
Executable file
8
ProjetInitial/Pilotes/Include/RTC.h
Executable file
|
|
@ -0,0 +1,8 @@
|
|||
#ifndef RTC_H_
|
||||
#define RTC_H_
|
||||
#include <stm32f10x.h>
|
||||
void initRTC();
|
||||
int getTime();
|
||||
|
||||
|
||||
#endif // RTC_H_
|
||||
56
ProjetInitial/Pilotes/Source/ADC.c
Executable file
56
ProjetInitial/Pilotes/Source/ADC.c
Executable file
|
|
@ -0,0 +1,56 @@
|
|||
#include <stm32f10x.h>
|
||||
#include <ADC.h>
|
||||
#include <MyUart.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
//Pont diviseur du tension, coeff. = 1/13
|
||||
//Alors 13V -> 12V*1/13 = 0.92V
|
||||
|
||||
//Tension pile donné sur GPIOA.2
|
||||
void initADC(){
|
||||
//Initialisation de ADC
|
||||
|
||||
RCC->APB2ENR |= (0x1<<10); //Initialisation du clock interne du ADC2
|
||||
RCC->APB2ENR |= (0x1<<2); //GPIOA clk enable
|
||||
ADC2->CR2 |= (0x1); // ON/OFF ADC2
|
||||
|
||||
//Init de la broche PA2 en mode analog input
|
||||
GPIOA->CRL &= ~(0x00000F00);
|
||||
|
||||
ADC2->CR2 |= (0x1<<20); //External trigger enable
|
||||
ADC2->CR2 |= (0b111<<17); //SWSTART
|
||||
ADC2->CR2 |= (0x1<<1); //Continous conversion
|
||||
ADC2->SQR3 = 2;
|
||||
|
||||
//Essai de faire un nouveau Threshold/Seuil
|
||||
ADC2->CR1 |= (0x1<<23); //Watchdog enable pour mettre un threshold HIGH
|
||||
ADC2->HTR &= ~(0x0FFF);
|
||||
|
||||
//########################MAHOUT AIDEZ NOUS############################æ
|
||||
//ADC2->HTR |= 0x0475; //Changement du threshold (0.92V/3.3V)*4096
|
||||
//ADC2->HTR |= 0x0BBB; //Faut demander le prof pour ce HIGH THRESHOLD
|
||||
ADC2->CR2 |= (0x1); //ON ADC2
|
||||
}
|
||||
|
||||
int recupADC(){
|
||||
int data;
|
||||
data = ADC2->DR;
|
||||
return data;
|
||||
}
|
||||
|
||||
void sendinfoADC(){
|
||||
int valu = recupADC();
|
||||
char meld[60];
|
||||
char meld2[50];
|
||||
|
||||
int test = valu*3.3/4096;
|
||||
test = test*13*100/12;
|
||||
int tension = (13*valu)/ADC2->HTR;
|
||||
int p2 = (13*valu)/0x0FFF;
|
||||
snprintf(meld, sizeof(meld),"Pourcentage de la pile : riktig: %d next %d next %d \r\n", tension, test, p2);
|
||||
snprintf(meld2, sizeof(meld2),"Tension de la pile : %dV\r\n", tension);
|
||||
|
||||
USART_Send_String(USART1, meld2);
|
||||
}
|
||||
|
||||
92
ProjetInitial/Pilotes/Source/DriverGPIO.c
Executable file
92
ProjetInitial/Pilotes/Source/DriverGPIO.c
Executable file
|
|
@ -0,0 +1,92 @@
|
|||
#include <stm32f10x.h>
|
||||
#include "DriverGPIO.h"
|
||||
|
||||
// Constantes
|
||||
#define In_Floating 0x4
|
||||
#define In_PullDown 0x8
|
||||
#define In_PullUp 0x8
|
||||
#define In_Analog 0x0
|
||||
#define Out_Ppull 0x3
|
||||
#define Out_OD 0x7
|
||||
#define AltOut_Ppull 0xB
|
||||
#define AltOut_OD 0xF
|
||||
|
||||
|
||||
void MyGPIO_Init(GPIO_TypeDef * GPIO, char pin, char conf) {
|
||||
int shift_pin;
|
||||
|
||||
//Start clock for relevant GPIO
|
||||
if(GPIO == GPIOA) {
|
||||
RCC -> APB2ENR |= RCC_APB2ENR_IOPAEN;
|
||||
}
|
||||
else if(GPIO == GPIOB) {
|
||||
RCC -> APB2ENR |= RCC_APB2ENR_IOPBEN;
|
||||
}
|
||||
else if(GPIO == GPIOC) {
|
||||
RCC -> APB2ENR |= RCC_APB2ENR_IOPCEN;
|
||||
}
|
||||
else if(GPIO == GPIOD) {
|
||||
RCC -> APB2ENR |= RCC_APB2ENR_IOPDEN;
|
||||
}
|
||||
if(pin < 8) {//CRL zone
|
||||
shift_pin = pin*4;
|
||||
GPIO -> CRL &= ~(0xF << shift_pin);
|
||||
//PullUp and PullDown have the same conf number, so we need to change the ODR to diferenciate them both
|
||||
if(conf == In_PullUp) {
|
||||
GPIO -> CRL |= ( In_PullUp << shift_pin);
|
||||
GPIO -> ODR |= (1<<pin);
|
||||
}
|
||||
else if(conf == In_PullDown) {
|
||||
GPIO -> CRL |= ( In_PullDown << shift_pin);
|
||||
GPIO -> ODR &= ~(1<<pin);
|
||||
}
|
||||
else {
|
||||
GPIO -> CRL |= ( conf << shift_pin);
|
||||
}
|
||||
}
|
||||
else {//CRH zone
|
||||
shift_pin = (pin-8)*4;
|
||||
GPIO -> CRH &= ~(0xF << shift_pin);
|
||||
if(conf == In_PullUp) {
|
||||
GPIO -> CRH |= ( In_PullUp << shift_pin);
|
||||
GPIO -> ODR |= (1<<pin);
|
||||
}
|
||||
else if(conf == In_PullDown) {
|
||||
GPIO -> CRH |= ( In_PullDown << shift_pin);
|
||||
GPIO -> ODR &= ~(1<<pin);
|
||||
}
|
||||
else {
|
||||
GPIO -> CRH |= ( conf << shift_pin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int MyGPIO_Read(GPIO_TypeDef * GPIO, char GPIO_Pin) {
|
||||
return(GPIO -> IDR & (1 << GPIO_Pin));
|
||||
}
|
||||
|
||||
|
||||
void MyGPIO_Set(GPIO_TypeDef * GPIO, char GPIO_Pin) {
|
||||
GPIO -> BSRR = (1<<GPIO_Pin);//1 on set zone
|
||||
}
|
||||
|
||||
|
||||
void MyGPIO_Reset(GPIO_TypeDef * GPIO, char GPIO_Pin) {
|
||||
GPIO -> BSRR = (1<<(GPIO_Pin+16));//1 on reset zone
|
||||
}
|
||||
|
||||
|
||||
void MYGPIO_PinOn (GPIO_TypeDef *GPIO , char GPIO_Pin){
|
||||
GPIO->ODR |= (1<<GPIO_Pin);
|
||||
};
|
||||
|
||||
void MYGPIO_PinOff (GPIO_TypeDef *GPIO , char GPIO_Pin){
|
||||
GPIO->ODR &= ~(1<<GPIO_Pin);
|
||||
};
|
||||
|
||||
|
||||
void MyGPIO_Toggle(GPIO_TypeDef * GPIO, char GPIO_Pin) {
|
||||
GPIO -> ODR = GPIO -> ODR ^ (0x1 << GPIO_Pin);
|
||||
}
|
||||
|
||||
91
ProjetInitial/Pilotes/Source/Horloge.c
Executable file
91
ProjetInitial/Pilotes/Source/Horloge.c
Executable file
|
|
@ -0,0 +1,91 @@
|
|||
#include <stm32f10x.h>
|
||||
#include "Horloge.h"
|
||||
|
||||
static void (*TIM2_Appel)(void) = 0;
|
||||
static void (*TIM3_Appel)(void) = 0;
|
||||
static void (*TIM4_Appel)(void) = 0;
|
||||
|
||||
|
||||
void Timer_Init(TIM_TypeDef *Timer, unsigned short Autoreload, unsigned short Prescaler) {
|
||||
if (Timer == TIM1) {
|
||||
// On ne l'utilise JAMAIS!!
|
||||
RCC->APB2ENR |= RCC_APB2ENR_TIM1EN;
|
||||
}
|
||||
else if (Timer == TIM2) {
|
||||
TIM2->CR1 |= TIM_CR1_CEN;
|
||||
RCC->APB1ENR |= RCC_APB1ENR_TIM2EN;
|
||||
}
|
||||
else if (Timer == TIM3) {
|
||||
TIM3->CR1 |= TIM_CR1_CEN;
|
||||
RCC->APB1ENR |= RCC_APB1ENR_TIM3EN;
|
||||
}
|
||||
else if (Timer == TIM4) {
|
||||
TIM3->CR1 |= TIM_CR1_CEN;
|
||||
RCC->APB1ENR |= RCC_APB1ENR_TIM4EN;
|
||||
}
|
||||
Timer->ARR |= Autoreload;
|
||||
Timer->PSC |= Prescaler;
|
||||
Timer->EGR |= TIM_EGR_UG;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MyTimer_ActiveIT(TIM_TypeDef * Timer, char Prio, void(*Interrupt_fonc)(void)) { //On veut créer une fonction qui envoie un signal au cas où il y a debordement, avec une prioritaire, 0 plus importante 15 moins importante
|
||||
if (Timer == TIM2) {
|
||||
TIM2_Appel = Interrupt_fonc;
|
||||
|
||||
NVIC_EnableIRQ(TIM2_IRQn);
|
||||
NVIC_SetPriority(TIM2_IRQn, Prio);
|
||||
TIM2->DIER |= TIM_DIER_UIE; //Le registre DIER(Interrupt Enable Register) est mis au bit Update Interrupt, qui se commute lors d'un overflow
|
||||
TIM2->CR1 |= TIM_CR1_CEN; //Clock Enable
|
||||
}
|
||||
else if (Timer == TIM3) {
|
||||
TIM3_Appel = Interrupt_fonc;
|
||||
|
||||
NVIC_EnableIRQ(TIM3_IRQn);
|
||||
NVIC_SetPriority(TIM2_IRQn, Prio);
|
||||
TIM3->DIER |= TIM_DIER_UIE;
|
||||
TIM3->CR1 |= TIM_CR1_CEN;
|
||||
}
|
||||
else if (Timer == TIM4) {
|
||||
TIM4_Appel = Interrupt_fonc;
|
||||
|
||||
NVIC_EnableIRQ(TIM4_IRQn);
|
||||
NVIC_SetPriority(TIM4_IRQn, Prio);
|
||||
TIM4->DIER |= TIM_DIER_UIE;
|
||||
TIM4->CR1 |= TIM_CR1_CEN;
|
||||
}
|
||||
else if (Timer == TIM1) {
|
||||
// On n'utilise pas TIM1
|
||||
}
|
||||
else {
|
||||
// L'horloge n'existe pas
|
||||
}
|
||||
}
|
||||
|
||||
//La fonction TIM2_IRQHandler existe déjà dans le processeur, on l'a juste redifint, tel qu'à chaque overflow on met un bit 1 dans GPIOA_ODR
|
||||
void TIM2_IRQHandler(void) { //On redefinit le IRQHandler qui est déjà ecrit dans le code source
|
||||
if (TIM2->SR & TIM_SR_UIF) { //On met le bit de overflow à un dès qu'on a overflow
|
||||
TIM2->SR &= ~TIM_SR_UIF; //Remise à zero
|
||||
if (TIM2_Appel){TIM2_Appel();}
|
||||
}
|
||||
}
|
||||
|
||||
//La fonction TIM3_IRQHandler existe déjà dans le processeur, on l'a juste redifint, tel qu'à chaque overflow on met un bit 1 dans GPIOA_ODR
|
||||
void TIM3_IRQHandler(void) { //On redefinit le IRQHandler qui est déjà ecrit dans le code source
|
||||
if (TIM3->SR & TIM_SR_UIF) { //On met le bit de overflow à un dès qu'on a overflow
|
||||
TIM3->SR &= ~TIM_SR_UIF; //Remise à zero
|
||||
if (TIM3_Appel){TIM3_Appel();}
|
||||
}
|
||||
}
|
||||
|
||||
//La fonction TIM4_IRQHandler existe déjà dans le processeur, on l'a juste redifint, tel qu'à chaque overflow on met un bit 1 dans GPIOA_ODR
|
||||
void TIM4_IRQHandler(void) { //On redefinit le IRQHandler qui est déjà ecrit dans le code source
|
||||
if (TIM4->SR & TIM_SR_UIF) { //On met le bit de overflow à un dès qu'on a overflow
|
||||
TIM4->SR &= ~TIM_SR_UIF; //Remise à zero
|
||||
if (TIM4_Appel){TIM4_Appel();}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
9
ProjetInitial/Pilotes/Source/I2C.c
Executable file
9
ProjetInitial/Pilotes/Source/I2C.c
Executable file
|
|
@ -0,0 +1,9 @@
|
|||
#include <stm32f10x.h>
|
||||
#include "I2C.h"
|
||||
|
||||
|
||||
void initI2C() {
|
||||
RCC -> APB1ENR |= 0x1 << 21; // Enable clock
|
||||
I2C1 -> CR1 |= 0x1 << 0; // Peripheral enable
|
||||
I2C1 -> CR1 &= ~(0x1 << 1); // I2C mode
|
||||
}
|
||||
95
ProjetInitial/Pilotes/Source/MYGPIO.c
Executable file
95
ProjetInitial/Pilotes/Source/MYGPIO.c
Executable file
|
|
@ -0,0 +1,95 @@
|
|||
#include <stdlib.h>
|
||||
#include <stm32f10x.h>
|
||||
#include "MYGPIO.h"
|
||||
|
||||
|
||||
//FONCTIONS POUR LE DEL INTERNE
|
||||
void initGPIO_Interne(void) {
|
||||
RCC->APB2ENR |= (0x01 << 2) | (0x01 << 3) | (0x01 << 4) ;
|
||||
|
||||
//Start
|
||||
//CRL pour les 8 premiers portes, CRH pour les 8 dernières portes
|
||||
if (LED_PIN_INTERNE < 8) {
|
||||
LED_GPIO_INTERNE->CRL &= ~(0xF << (LED_PIN_INTERNE*4));
|
||||
LED_GPIO_INTERNE->CRL |= GPIO_OUTPUT_PPULL_MODE<<(LED_PIN_INTERNE*4) ; // On met tous les Pins de broche A à ANalog Input sauf broche PA.5 qui correspond au LED GREEN: Output 2MHz et GP output push-pull
|
||||
}
|
||||
else {
|
||||
LED_GPIO_INTERNE->CRH &= ~(0xF <<((LED_PIN_INTERNE-8)*4));
|
||||
LED_GPIO_INTERNE->CRH |= GPIO_OUTPUT_PPULL_MODE<<((LED_PIN_INTERNE-8)*4);
|
||||
}
|
||||
|
||||
if (BUTTON_PIN_INTERNE < 8) {
|
||||
BUTTON_GPIO_INTERNE->CRL &= ~(0xF << (BUTTON_PIN_INTERNE*4));
|
||||
BUTTON_GPIO_INTERNE->CRL |= GPIO_INPUT_FLOATING_MODE<<(BUTTON_PIN_INTERNE*4) ; // On met tous les Pins de broche A à ANalog Input sauf broche PA.5 qui correspond au LED GREEN: Output 2MHz et GP output push-pull
|
||||
}
|
||||
else {
|
||||
BUTTON_GPIO_INTERNE->CRH &= ~(0xF <<((BUTTON_PIN_INTERNE-8)*4));
|
||||
BUTTON_GPIO_INTERNE->CRH |= GPIO_INPUT_FLOATING_MODE<<((BUTTON_PIN_INTERNE-8)*4);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int boutonAppuye_Interne(void) {
|
||||
return BUTTON_GPIO_INTERNE->IDR &(1<<BUTTON_PIN_INTERNE);
|
||||
}
|
||||
|
||||
|
||||
void allumerDEL_Interne(void) {
|
||||
LED_GPIO_INTERNE->ODR |= (0x01 << LED_PIN_INTERNE) ; //On essaie de mettre en position PA5 de GPIOC_ODR un 1 comme ca allume le LED GREEN
|
||||
}
|
||||
|
||||
|
||||
void eteindreDEL_Interne(void) { // Allumer un LED externe, PB8/D15 OUTPUT, Bouton Poussoir PB9/D14
|
||||
LED_GPIO_INTERNE->ODR &= ~(0x01 << LED_PIN_EXTERNE) ; //On essaie de mettre en position PA5 de GPIOC_ODR un 0 comme ca eteint le LED GREEN
|
||||
}
|
||||
|
||||
|
||||
void commuterDEL_Interne(void) {
|
||||
LED_GPIO_INTERNE->ODR ^= (0x01 << LED_PIN_INTERNE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//FONCTIONS POUR LE DEL EXTERNE
|
||||
void initGPIO_Externe(void) {
|
||||
RCC->APB2ENR |= (0x01 << 2) | (0x01 << 3) | (0x01 << 4) ;
|
||||
|
||||
// CRL pour les 8 premiers portes, CRH pour les 8 dernières portes
|
||||
if (LED_PIN_EXTERNE < 8) {
|
||||
LED_GPIO_EXTERNE->CRL &= ~(0xF << (LED_PIN_EXTERNE*4));
|
||||
LED_GPIO_EXTERNE->CRL |= GPIO_OUTPUT_PPULL_MODE<<(LED_PIN_EXTERNE*4) ; // On met tous les Pins de broche A à ANalog Input sauf broche PA.5 qui correspond au LED GREEN: Output 2MHz et GP output push-pull
|
||||
}
|
||||
else {
|
||||
LED_GPIO_EXTERNE->CRH &= ~(0xF <<((LED_PIN_EXTERNE-8)*4));
|
||||
LED_GPIO_EXTERNE->CRH |= GPIO_OUTPUT_PPULL_MODE<<((LED_PIN_EXTERNE-8)*4);
|
||||
}
|
||||
if (BUTTON_PIN_EXTERNE < 8) {
|
||||
BUTTON_GPIO_EXTERNE->CRL &= ~(0xF << (BUTTON_PIN_EXTERNE*4));
|
||||
BUTTON_GPIO_EXTERNE->CRL |= GPIO_INPUT_FLOATING_MODE<<(BUTTON_PIN_EXTERNE*4) ; // On met tous les Pins de broche A à ANalog Input sauf broche PA.5 qui correspond au LED GREEN: Output 2MHz et GP output push-pull
|
||||
}
|
||||
else {
|
||||
BUTTON_GPIO_EXTERNE->CRH &= ~(0xF <<((BUTTON_PIN_EXTERNE-8)*4));
|
||||
BUTTON_GPIO_EXTERNE->CRH |= GPIO_INPUT_FLOATING_MODE<<((BUTTON_PIN_EXTERNE-8)*4);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int boutonAppuye_Externe(void) {
|
||||
return BUTTON_GPIO_EXTERNE->IDR &(1<<BUTTON_PIN_EXTERNE);
|
||||
}
|
||||
|
||||
|
||||
void allumerDEL_Externe(void) { // On essaie de mettre en position PA5 de GPIOC_ODR un 1 comme ca allume le LED GREEN
|
||||
LED_GPIO_EXTERNE->ODR |= (0x01 << LED_PIN_EXTERNE) ;
|
||||
}
|
||||
|
||||
|
||||
void eteindreDEL_Externe(void) { // Allumer un LED externe, PB8/D15 OUTPUT, Bouton Poussoir PB9/D14
|
||||
LED_GPIO_EXTERNE->ODR &= ~(0x01 << LED_PIN_EXTERNE) ; // On essaie de mettre en position PA5 de GPIOC_ODR un 0 comme ca eteint le LED GREEN
|
||||
}
|
||||
|
||||
|
||||
void commuterDEL_Externe(void) {
|
||||
LED_GPIO_EXTERNE->ODR ^= (0x01 << LED_PIN_EXTERNE);
|
||||
}
|
||||
|
||||
55
ProjetInitial/Pilotes/Source/MyUart.c
Executable file
55
ProjetInitial/Pilotes/Source/MyUart.c
Executable file
|
|
@ -0,0 +1,55 @@
|
|||
#include <stm32f10x.h>
|
||||
#include "DriverGPIO.h"
|
||||
|
||||
|
||||
|
||||
void My_USART_Config(USART_TypeDef* USARTx, uint32_t baudrate) { //QUE POUR USART_CR1_RE
|
||||
// Configuration PA9 (Tx) en Alternate Function Push-Pull
|
||||
MyGPIO_Init(GPIOA, 9 , AltOut_Ppull);
|
||||
// Configuration PA10 (Rx) en Input Floating
|
||||
MyGPIO_Init(GPIOA, 10 , In_Floating);
|
||||
NVIC_EnableIRQ(USART1_IRQn);
|
||||
NVIC_SetPriority(USART1_IRQn, 3<<4);
|
||||
|
||||
RCC->APB2ENR |= RCC_APB2ENR_USART1EN;
|
||||
USARTx->CR1 |= USART_CR1_UE;
|
||||
USARTx->BRR = baudrate;
|
||||
USARTx->CR1 |= USART_CR1_TE;
|
||||
USARTx->CR1 |= USART_CR1_RE;
|
||||
};
|
||||
|
||||
|
||||
void USART_Send_Char(USART_TypeDef* USARTx, char car) {
|
||||
while ((USARTx->SR & USART_SR_TXE)==0){}
|
||||
USARTx->DR = car;
|
||||
};
|
||||
|
||||
|
||||
void USART_Send_String(USART_TypeDef *USARTx, char *pString) {
|
||||
while (*pString != '\0') {
|
||||
USART_Send_Char(USARTx, *pString);
|
||||
pString++;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
void (*pFnc_Receive)(char);
|
||||
|
||||
|
||||
void USART_IT_Receive_Enable(USART_TypeDef* USARTx) {
|
||||
USARTx->CR1 |= USART_CR1_RXNEIE;
|
||||
};
|
||||
|
||||
|
||||
void Init_IT_Receive(void (*Receive_IT_function) (char)) {
|
||||
pFnc_Receive = Receive_IT_function;
|
||||
};
|
||||
|
||||
|
||||
void USART1_IRQHandler(void) {
|
||||
signed char commande = USART1->DR;
|
||||
if (pFnc_Receive != 0) {
|
||||
pFnc_Receive(commande);
|
||||
}
|
||||
};
|
||||
|
||||
140
ProjetInitial/Pilotes/Source/PWM.c
Executable file
140
ProjetInitial/Pilotes/Source/PWM.c
Executable file
|
|
@ -0,0 +1,140 @@
|
|||
#include "stm32f10x.h"
|
||||
#include "Horloge.h"
|
||||
#include "DriverGPIO.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
void My_PWM_Channel_Config(TIM_TypeDef* Timer , char channel){
|
||||
switch (channel) {
|
||||
case 1:
|
||||
// Configuration de CC1
|
||||
Timer->CCMR1 &= ~TIM_CCMR1_CC1S; // Output
|
||||
Timer->CCMR1 |= TIM_CCMR1_OC1M_2 | TIM_CCMR1_OC1M_1; // Mode PWM 1 (0b110)
|
||||
Timer->CCMR1 |= TIM_CCMR1_OC1PE; // Preload Enable
|
||||
Timer->CCR1 = 0;
|
||||
Timer->CCER |= TIM_CCER_CC1E; // Output Enable
|
||||
break; // <<-- AJOUTER LE BREAK
|
||||
|
||||
case 2:
|
||||
// Configuration de CC2 (vos registres dans le code initial étaient incohérents)
|
||||
Timer->CCMR1 &= ~TIM_CCMR1_CC2S; // Output
|
||||
Timer->CCMR1 |= TIM_CCMR1_OC2M_2 | TIM_CCMR1_OC2M_1; // Mode PWM 1 (0b110)
|
||||
Timer->CCMR1 |= TIM_CCMR1_OC2PE; // Preload Enable
|
||||
Timer->CCR2 = 0;
|
||||
Timer->CCER |= TIM_CCER_CC2E; // Output Enable
|
||||
break;}
|
||||
|
||||
Timer->CR1 |= TIM_CR1_ARPE; // Auto-Reload Preload
|
||||
Timer->BDTR |= TIM_BDTR_MOE; // Main Output Enable (pour les timers avancés TIM1/8)
|
||||
Timer->EGR |= TIM_EGR_UG;
|
||||
Timer->CR1 |= TIM_CR1_CEN;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
void MyTimer_PWM(TIM_TypeDef * Timer , int Channel){
|
||||
int pwrmd;
|
||||
#if POWERMODE //Powermode 1
|
||||
pwrmd = 0b110;
|
||||
#else
|
||||
pwrmd = 0b110; //Powermode 2
|
||||
#endif
|
||||
|
||||
if (Channel == 1){
|
||||
Timer->CCMR1 &= ~(0b111<<4); //On clear les trois bits qui sont de pwm
|
||||
Timer->CCMR1 |= (pwrmd<<4); //On affecte le powermode au bits de lecture pour le µ-controlleur
|
||||
Timer->CCMR1 |= TIM_CCMR1_OC1PE; //Update preload, il n'affecte pas le valeur avant que la prochaine cycle
|
||||
Timer->CCER = TIM_CCER_CC1E; //Enable le pin voulu basculer
|
||||
}
|
||||
else if (Channel == 2){
|
||||
Timer->CCMR1 &= ~(0b111<<12); //Le TIMx_CCMR1 configure deux channels, de bit [6:4] CH1, [14:12] CH2 (OC2M = Output Channel 2 )
|
||||
Timer->CCMR1 |= (pwrmd<<12);
|
||||
Timer->CCMR1 |= TIM_CCMR1_OC2PE;
|
||||
Timer->CCER |= TIM_CCER_CC2E;
|
||||
}
|
||||
else if (Channel == 3){
|
||||
Timer->CCMR1 &= ~(0b111<<4);
|
||||
Timer->CCMR2 |= (pwrmd<<4);
|
||||
Timer->CCMR2 |= TIM_CCMR2_OC3PE;
|
||||
Timer->CCER |= TIM_CCER_CC3E;
|
||||
}
|
||||
else if (Channel == 4){
|
||||
Timer->CCMR1 &= ~(0b111<<12);
|
||||
Timer->CCMR2 |= (pwrmd<<12);
|
||||
Timer->CCMR2 |= TIM_CCMR2_OC4PE;
|
||||
Timer->CCER |= TIM_CCER_CC4E;
|
||||
}
|
||||
|
||||
//En dessous d'ici, on a l'aide du plus gentil chat que je connais
|
||||
// Enable auto-reload preload -- //Ensures that your initial configuration — PWM mode, duty cycle, period — actually takes effect before the timer starts counting.
|
||||
Timer->CR1 |= TIM_CR1_ARPE;
|
||||
// Force update event to load ARR and CCR values immediately
|
||||
Timer->EGR |= TIM_EGR_UG;
|
||||
// Start the timer
|
||||
Timer->CR1 |= TIM_CR1_CEN;
|
||||
|
||||
switch (Channel) {
|
||||
case 1:
|
||||
if (Timer == TIM1){GPIOA->CRH &=
|
||||
~(0xF<<0*4); GPIOA->CRH |= (0xA<<0*4); TIM1->BDTR |= 1<<15; }
|
||||
if (Timer == TIM2){GPIOA->CRL &=
|
||||
~(0xF<<0*4); GPIOA->CRL |= (0xA<<0*4);}
|
||||
if (Timer == TIM3){GPIOA->CRL &=
|
||||
~(0xF<<6*4); GPIOA->CRL |= (0xA<<6*4);}
|
||||
if (Timer == TIM4){GPIOB->CRL &=
|
||||
~(0xF<<5*4); GPIOB->CRL |= (0xA<<5*4);}
|
||||
break;
|
||||
case 2:
|
||||
if (Timer == TIM1){GPIOA->CRH &=
|
||||
~(0xF<<1*4); GPIOA->CRL |= (0xA<<1*4); TIM1->BDTR |= 1<<15;}
|
||||
if (Timer == TIM2){GPIOA->CRL &=
|
||||
~(0xF<<1*4); GPIOA->CRL |= (0xA<<1*4);}
|
||||
if (Timer == TIM3){GPIOA->CRL &=
|
||||
~(0xF<<7*4); GPIOA->CRL |= (0xA<<7*4);}
|
||||
if (Timer == TIM4){GPIOB->CRL &=
|
||||
~(0xF<<7*4); GPIOB->CRL |= (0xA<<7*4);}
|
||||
break;
|
||||
case 3:
|
||||
if (Timer == TIM1){GPIOA->CRH &=
|
||||
~(0xF<<2*4); GPIOA->CRH |= (0xA<<2*4); TIM1->BDTR |= 1<<15;}
|
||||
if (Timer == TIM2){GPIOA->CRL &=
|
||||
~(0xF<<2*4); GPIOA->CRL |= (0xA<<2*4);}
|
||||
if (Timer == TIM3){GPIOB->CRL &=
|
||||
~(0xF<<0*4); GPIOB->CRL |= (0xA<<0*4);}
|
||||
if (Timer == TIM4){GPIOB->CRH &=
|
||||
~(0xF<<0*4); GPIOB->CRH |= (0xA<<0*4);}
|
||||
break;
|
||||
case 4:
|
||||
if (Timer == TIM1){GPIOA->CRH &=
|
||||
~(0xF<<3*4); GPIOA->CRH |= (0xA<<3*4); TIM1->BDTR |= 1<<15;}
|
||||
if (Timer == TIM2){GPIOA->CRL &=
|
||||
~(0xF<<3*4); GPIOA->CRL |= (0xA<<3*4);}
|
||||
if (Timer == TIM3){GPIOB->CRL &=
|
||||
~(0xF<<1*4); GPIOB->CRL |= (0xA<<1*4);}
|
||||
if (Timer == TIM4){GPIOB->CRH &=
|
||||
~(0xF<<1*4); GPIOB->CRH |= (0xA<<1*4);}
|
||||
|
||||
}
|
||||
}
|
||||
int Set_DutyCycle_PWM(TIM_TypeDef *Timer, int Channel, int DutyC){
|
||||
int CCR_VAL = (Timer->ARR + 1) * DutyC / 100;
|
||||
switch (Channel){
|
||||
case 1:
|
||||
Timer->CCR1 = CCR_VAL;
|
||||
break;
|
||||
case 2:
|
||||
Timer->CCR2 = CCR_VAL;
|
||||
break;
|
||||
case 3:
|
||||
|
||||
Timer->CCR3 = CCR_VAL;
|
||||
break;
|
||||
case 4:
|
||||
Timer->CCR4 = CCR_VAL;
|
||||
break;
|
||||
default:
|
||||
return -1; // channel invalide
|
||||
}
|
||||
Timer->EGR |= TIM_EGR_UG; // update event
|
||||
return 0;
|
||||
}
|
||||
35
ProjetInitial/Pilotes/Source/Plateau.c
Executable file
35
ProjetInitial/Pilotes/Source/Plateau.c
Executable file
|
|
@ -0,0 +1,35 @@
|
|||
#include "stm32f10x.h"
|
||||
#include "PWM.h"
|
||||
#include "DriverGPIO.h"
|
||||
#include "Horloge.h"
|
||||
|
||||
void initPlato(TIM_TypeDef * Timer, int Channel) { // Config du moteur servo
|
||||
MyGPIO_Init(GPIOB, 5, AltOut_Ppull); //config pin de direction 0 ou 1
|
||||
if (Timer == TIM3) {
|
||||
Timer_Init(TIM3, 159, 17); // Pour obtenir fréq de 20kHZ
|
||||
if (Channel == 3) {
|
||||
MyGPIO_Init(GPIOB, 0, AltOut_Ppull); // Outut push pull alternate, config pin de consigne entre -100 et 100
|
||||
MyTimer_PWM(TIM3, 3); //TIM3 CH3
|
||||
}
|
||||
else {
|
||||
//printf("Ce pilote n'existe pas");
|
||||
}
|
||||
}
|
||||
else {
|
||||
//printf("Ce pilote n'existe pas");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Update_Motor_PWM(int Consigne, TIM_TypeDef * Timer, int Channel) {
|
||||
int duty_cycle;
|
||||
if (Consigne>=0) {
|
||||
MyGPIO_Set(GPIOB, 5);
|
||||
duty_cycle = Consigne;
|
||||
}
|
||||
if (Consigne<0){
|
||||
MyGPIO_Reset(GPIOB,5);
|
||||
duty_cycle = -Consigne;
|
||||
}
|
||||
Set_DutyCycle_PWM_Plateau(Timer, Channel, duty_cycle);
|
||||
}
|
||||
671
ProjetInitial/Projet0.uvoptx
Executable file
671
ProjetInitial/Projet0.uvoptx
Executable file
|
|
@ -0,0 +1,671 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||
<ProjectOpt xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="project_optx.xsd">
|
||||
|
||||
<SchemaVersion>1.0</SchemaVersion>
|
||||
|
||||
<Header>### uVision Project, (C) Keil Software</Header>
|
||||
|
||||
<Extensions>
|
||||
<cExt>*.c</cExt>
|
||||
<aExt>*.s*; *.src; *.a*</aExt>
|
||||
<oExt>*.obj; *.o</oExt>
|
||||
<lExt>*.lib</lExt>
|
||||
<tExt>*.txt; *.h; *.inc; *.md</tExt>
|
||||
<pExt>*.plm</pExt>
|
||||
<CppX>*.cpp; *.cc; *.cxx</CppX>
|
||||
<nMigrate>0</nMigrate>
|
||||
</Extensions>
|
||||
|
||||
<DaveTm>
|
||||
<dwLowDateTime>0</dwLowDateTime>
|
||||
<dwHighDateTime>0</dwHighDateTime>
|
||||
</DaveTm>
|
||||
|
||||
<Target>
|
||||
<TargetName>Reel</TargetName>
|
||||
<ToolsetNumber>0x4</ToolsetNumber>
|
||||
<ToolsetName>ARM-ADS</ToolsetName>
|
||||
<TargetOption>
|
||||
<CLKADS>8000000</CLKADS>
|
||||
<OPTTT>
|
||||
<gFlags>1</gFlags>
|
||||
<BeepAtEnd>1</BeepAtEnd>
|
||||
<RunSim>0</RunSim>
|
||||
<RunTarget>1</RunTarget>
|
||||
<RunAbUc>0</RunAbUc>
|
||||
</OPTTT>
|
||||
<OPTHX>
|
||||
<HexSelection>1</HexSelection>
|
||||
<FlashByte>65535</FlashByte>
|
||||
<HexRangeLowAddress>0</HexRangeLowAddress>
|
||||
<HexRangeHighAddress>0</HexRangeHighAddress>
|
||||
<HexOffset>0</HexOffset>
|
||||
</OPTHX>
|
||||
<OPTLEX>
|
||||
<PageWidth>79</PageWidth>
|
||||
<PageLength>66</PageLength>
|
||||
<TabStop>8</TabStop>
|
||||
<ListingPath>.\Listings\</ListingPath>
|
||||
</OPTLEX>
|
||||
<ListingPage>
|
||||
<CreateCListing>1</CreateCListing>
|
||||
<CreateAListing>1</CreateAListing>
|
||||
<CreateLListing>1</CreateLListing>
|
||||
<CreateIListing>0</CreateIListing>
|
||||
<AsmCond>1</AsmCond>
|
||||
<AsmSymb>1</AsmSymb>
|
||||
<AsmXref>0</AsmXref>
|
||||
<CCond>1</CCond>
|
||||
<CCode>0</CCode>
|
||||
<CListInc>0</CListInc>
|
||||
<CSymb>0</CSymb>
|
||||
<LinkerCodeListing>0</LinkerCodeListing>
|
||||
</ListingPage>
|
||||
<OPTXL>
|
||||
<LMap>1</LMap>
|
||||
<LComments>1</LComments>
|
||||
<LGenerateSymbols>1</LGenerateSymbols>
|
||||
<LLibSym>1</LLibSym>
|
||||
<LLines>1</LLines>
|
||||
<LLocSym>1</LLocSym>
|
||||
<LPubSym>1</LPubSym>
|
||||
<LXref>0</LXref>
|
||||
<LExpSel>0</LExpSel>
|
||||
</OPTXL>
|
||||
<OPTFL>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<IsCurrentTarget>1</IsCurrentTarget>
|
||||
</OPTFL>
|
||||
<CpuCode>18</CpuCode>
|
||||
<DebugOpt>
|
||||
<uSim>0</uSim>
|
||||
<uTrg>1</uTrg>
|
||||
<sLdApp>1</sLdApp>
|
||||
<sGomain>1</sGomain>
|
||||
<sRbreak>1</sRbreak>
|
||||
<sRwatch>1</sRwatch>
|
||||
<sRmem>1</sRmem>
|
||||
<sRfunc>1</sRfunc>
|
||||
<sRbox>1</sRbox>
|
||||
<tLdApp>1</tLdApp>
|
||||
<tGomain>1</tGomain>
|
||||
<tRbreak>1</tRbreak>
|
||||
<tRwatch>1</tRwatch>
|
||||
<tRmem>1</tRmem>
|
||||
<tRfunc>0</tRfunc>
|
||||
<tRbox>1</tRbox>
|
||||
<tRtrace>1</tRtrace>
|
||||
<sRSysVw>1</sRSysVw>
|
||||
<tRSysVw>1</tRSysVw>
|
||||
<sRunDeb>0</sRunDeb>
|
||||
<sLrtime>0</sLrtime>
|
||||
<bEvRecOn>1</bEvRecOn>
|
||||
<bSchkAxf>0</bSchkAxf>
|
||||
<bTchkAxf>0</bTchkAxf>
|
||||
<nTsel>6</nTsel>
|
||||
<sDll></sDll>
|
||||
<sDllPa></sDllPa>
|
||||
<sDlgDll></sDlgDll>
|
||||
<sDlgPa></sDlgPa>
|
||||
<sIfile>.\simu.ini</sIfile>
|
||||
<tDll></tDll>
|
||||
<tDllPa></tDllPa>
|
||||
<tDlgDll></tDlgDll>
|
||||
<tDlgPa></tDlgPa>
|
||||
<tIfile>.\reel.ini</tIfile>
|
||||
<pMon>STLink\ST-LINKIII-KEIL_SWO.dll</pMon>
|
||||
</DebugOpt>
|
||||
<TargetDriverDllRegistry>
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
<Key>ARMRTXEVENTFLAGS</Key>
|
||||
<Name>-L70 -Z18 -C0 -M0 -T1</Name>
|
||||
</SetRegEntry>
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
<Key>DLGTARM</Key>
|
||||
<Name>(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(100=638,234,1284,907,0)(110=-1,-1,-1,-1,0)(111=-1,-1,-1,-1,0)(1011=-1,-1,-1,-1,0)(180=-1,-1,-1,-1,0)(120=777,701,1198,1106,0)(121=1276,605,1697,1010,0)(122=1419,197,1840,602,0)(123=-1,-1,-1,-1,0)(140=-1,-1,-1,-1,0)(240=-1,-1,-1,-1,0)(190=-1,-1,-1,-1,0)(200=-1,-1,-1,-1,0)(170=-1,-1,-1,-1,0)(130=-1,-1,-1,-1,0)(131=87,413,681,1107,0)(132=-1,-1,-1,-1,0)(133=937,506,1531,1200,0)(160=-1,-1,-1,-1,0)(161=-1,-1,-1,-1,0)(162=-1,-1,-1,-1,0)(210=-1,-1,-1,-1,0)(211=-1,-1,-1,-1,0)(220=-1,-1,-1,-1,0)(221=-1,-1,-1,-1,0)(230=-1,-1,-1,-1,0)(231=-1,-1,-1,-1,0)(232=-1,-1,-1,-1,0)(233=-1,-1,-1,-1,0)(150=-1,-1,-1,-1,0)(151=-1,-1,-1,-1,0)</Name>
|
||||
</SetRegEntry>
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
<Key>ARMDBGFLAGS</Key>
|
||||
<Name></Name>
|
||||
</SetRegEntry>
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
<Key>DLGUARM</Key>
|
||||
<Name>(105=-1,-1,-1,-1,0)</Name>
|
||||
</SetRegEntry>
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
<Key>ST-LINKIII-KEIL_SWO</Key>
|
||||
<Name>-U066EFF323535474B43174430 -O206 -SF10000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP (ARM Core") -D00(1BA01477) -L00(0) -TO131090 -TC10000000 -TT10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC1000 -FN1 -FF0STM32F10x_128.FLM -FS08000000 -FL020000 -FP0($$Device:STM32F103RB$Flash\STM32F10x_128.FLM) -WA0 -WE0 -WVCE4 -WS2710 -WM0 -WP2 -WK0-R0</Name>
|
||||
</SetRegEntry>
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
<Key>UL2CM3</Key>
|
||||
<Name>UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32F10x_128 -FS08000000 -FL020000 -FP0($$Device:STM32F103RB$Flash\STM32F10x_128.FLM))</Name>
|
||||
</SetRegEntry>
|
||||
</TargetDriverDllRegistry>
|
||||
<Breakpoint/>
|
||||
<WatchWindow1>
|
||||
<Ww>
|
||||
<count>0</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>angleVentVar,0x0A</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>1</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>angleVoileVar,0x0A</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>2</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>moy,0x0A</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>3</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>Val_lim</ItemText>
|
||||
</Ww>
|
||||
</WatchWindow1>
|
||||
<WatchWindow2>
|
||||
<Ww>
|
||||
<count>0</count>
|
||||
<WinNumber>2</WinNumber>
|
||||
<ItemText>angleVoileVar</ItemText>
|
||||
</Ww>
|
||||
</WatchWindow2>
|
||||
<Tracepoint>
|
||||
<THDelay>0</THDelay>
|
||||
</Tracepoint>
|
||||
<DebugFlag>
|
||||
<trace>0</trace>
|
||||
<periodic>1</periodic>
|
||||
<aLwin>1</aLwin>
|
||||
<aCover>0</aCover>
|
||||
<aSer1>0</aSer1>
|
||||
<aSer2>0</aSer2>
|
||||
<aPa>0</aPa>
|
||||
<viewmode>1</viewmode>
|
||||
<vrSel>0</vrSel>
|
||||
<aSym>0</aSym>
|
||||
<aTbox>0</aTbox>
|
||||
<AscS1>0</AscS1>
|
||||
<AscS2>0</AscS2>
|
||||
<AscS3>0</AscS3>
|
||||
<aSer3>0</aSer3>
|
||||
<eProf>0</eProf>
|
||||
<aLa>1</aLa>
|
||||
<aPa1>0</aPa1>
|
||||
<AscS4>0</AscS4>
|
||||
<aSer4>0</aSer4>
|
||||
<StkLoc>0</StkLoc>
|
||||
<TrcWin>0</TrcWin>
|
||||
<newCpu>0</newCpu>
|
||||
<uProt>0</uProt>
|
||||
</DebugFlag>
|
||||
<LintExecutable></LintExecutable>
|
||||
<LintConfigFile></LintConfigFile>
|
||||
<bLintAuto>0</bLintAuto>
|
||||
<bAutoGenD>0</bAutoGenD>
|
||||
<LntExFlags>0</LntExFlags>
|
||||
<pMisraName></pMisraName>
|
||||
<pszMrule></pszMrule>
|
||||
<pSingCmds></pSingCmds>
|
||||
<pMultCmds></pMultCmds>
|
||||
<pMisraNamep></pMisraNamep>
|
||||
<pszMrulep></pszMrulep>
|
||||
<pSingCmdsp></pSingCmdsp>
|
||||
<pMultCmdsp></pMultCmdsp>
|
||||
<DebugDescription>
|
||||
<Enable>1</Enable>
|
||||
<EnableFlashSeq>0</EnableFlashSeq>
|
||||
<EnableLog>0</EnableLog>
|
||||
<Protocol>2</Protocol>
|
||||
<DbgClock>10000000</DbgClock>
|
||||
</DebugDescription>
|
||||
</TargetOption>
|
||||
</Target>
|
||||
|
||||
<Target>
|
||||
<TargetName>Simulation</TargetName>
|
||||
<ToolsetNumber>0x4</ToolsetNumber>
|
||||
<ToolsetName>ARM-ADS</ToolsetName>
|
||||
<TargetOption>
|
||||
<CLKADS>8000000</CLKADS>
|
||||
<OPTTT>
|
||||
<gFlags>1</gFlags>
|
||||
<BeepAtEnd>0</BeepAtEnd>
|
||||
<RunSim>0</RunSim>
|
||||
<RunTarget>1</RunTarget>
|
||||
<RunAbUc>0</RunAbUc>
|
||||
</OPTTT>
|
||||
<OPTHX>
|
||||
<HexSelection>1</HexSelection>
|
||||
<FlashByte>65535</FlashByte>
|
||||
<HexRangeLowAddress>0</HexRangeLowAddress>
|
||||
<HexRangeHighAddress>0</HexRangeHighAddress>
|
||||
<HexOffset>0</HexOffset>
|
||||
</OPTHX>
|
||||
<OPTLEX>
|
||||
<PageWidth>79</PageWidth>
|
||||
<PageLength>66</PageLength>
|
||||
<TabStop>8</TabStop>
|
||||
<ListingPath>.\Listings\</ListingPath>
|
||||
</OPTLEX>
|
||||
<ListingPage>
|
||||
<CreateCListing>1</CreateCListing>
|
||||
<CreateAListing>1</CreateAListing>
|
||||
<CreateLListing>1</CreateLListing>
|
||||
<CreateIListing>0</CreateIListing>
|
||||
<AsmCond>1</AsmCond>
|
||||
<AsmSymb>1</AsmSymb>
|
||||
<AsmXref>0</AsmXref>
|
||||
<CCond>1</CCond>
|
||||
<CCode>0</CCode>
|
||||
<CListInc>0</CListInc>
|
||||
<CSymb>0</CSymb>
|
||||
<LinkerCodeListing>0</LinkerCodeListing>
|
||||
</ListingPage>
|
||||
<OPTXL>
|
||||
<LMap>1</LMap>
|
||||
<LComments>1</LComments>
|
||||
<LGenerateSymbols>1</LGenerateSymbols>
|
||||
<LLibSym>1</LLibSym>
|
||||
<LLines>1</LLines>
|
||||
<LLocSym>1</LLocSym>
|
||||
<LPubSym>1</LPubSym>
|
||||
<LXref>0</LXref>
|
||||
<LExpSel>0</LExpSel>
|
||||
</OPTXL>
|
||||
<OPTFL>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<IsCurrentTarget>0</IsCurrentTarget>
|
||||
</OPTFL>
|
||||
<CpuCode>18</CpuCode>
|
||||
<DebugOpt>
|
||||
<uSim>1</uSim>
|
||||
<uTrg>0</uTrg>
|
||||
<sLdApp>1</sLdApp>
|
||||
<sGomain>1</sGomain>
|
||||
<sRbreak>1</sRbreak>
|
||||
<sRwatch>1</sRwatch>
|
||||
<sRmem>1</sRmem>
|
||||
<sRfunc>1</sRfunc>
|
||||
<sRbox>1</sRbox>
|
||||
<tLdApp>1</tLdApp>
|
||||
<tGomain>1</tGomain>
|
||||
<tRbreak>1</tRbreak>
|
||||
<tRwatch>1</tRwatch>
|
||||
<tRmem>1</tRmem>
|
||||
<tRfunc>0</tRfunc>
|
||||
<tRbox>1</tRbox>
|
||||
<tRtrace>1</tRtrace>
|
||||
<sRSysVw>1</sRSysVw>
|
||||
<tRSysVw>1</tRSysVw>
|
||||
<sRunDeb>0</sRunDeb>
|
||||
<sLrtime>0</sLrtime>
|
||||
<bEvRecOn>1</bEvRecOn>
|
||||
<bSchkAxf>0</bSchkAxf>
|
||||
<bTchkAxf>0</bTchkAxf>
|
||||
<nTsel>6</nTsel>
|
||||
<sDll></sDll>
|
||||
<sDllPa></sDllPa>
|
||||
<sDlgDll></sDlgDll>
|
||||
<sDlgPa></sDlgPa>
|
||||
<sIfile>.\simu.ini</sIfile>
|
||||
<tDll></tDll>
|
||||
<tDllPa></tDllPa>
|
||||
<tDlgDll></tDlgDll>
|
||||
<tDlgPa></tDlgPa>
|
||||
<tIfile>.\simu.ini</tIfile>
|
||||
<pMon>STLink\ST-LINKIII-KEIL_SWO.dll</pMon>
|
||||
</DebugOpt>
|
||||
<TargetDriverDllRegistry>
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
<Key>ARMRTXEVENTFLAGS</Key>
|
||||
<Name>-L70 -Z18 -C0 -M0 -T1</Name>
|
||||
</SetRegEntry>
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
<Key>DLGDARM</Key>
|
||||
<Name>(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(100=638,234,1284,907,0)(110=1085,167,1305,627,0)(111=1025,230,1245,690,0)(1011=-1,-1,-1,-1,0)(180=-1,-1,-1,-1,0)(120=835,180,1256,607,0)(121=1311,520,1732,947,1)(122=-1,-1,-1,-1,0)(123=-1,-1,-1,-1,0)(140=-1,-1,-1,-1,0)(240=-1,-1,-1,-1,0)(190=-1,-1,-1,-1,0)(200=-1,-1,-1,-1,0)(170=-1,-1,-1,-1,0)(130=-1,-1,-1,-1,0)(131=-1,-1,-1,-1,0)(132=-1,-1,-1,-1,0)(133=1162,203,1756,954,1)(160=-1,-1,-1,-1,0)(161=-1,-1,-1,-1,0)(162=-1,-1,-1,-1,0)(210=-1,-1,-1,-1,0)(211=-1,-1,-1,-1,0)(220=-1,-1,-1,-1,0)(221=-1,-1,-1,-1,0)(230=-1,-1,-1,-1,0)(234=-1,-1,-1,-1,0)(231=-1,-1,-1,-1,0)(232=-1,-1,-1,-1,0)(233=-1,-1,-1,-1,0)(150=-1,-1,-1,-1,0)(151=-1,-1,-1,-1,0)</Name>
|
||||
</SetRegEntry>
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
<Key>ARMDBGFLAGS</Key>
|
||||
<Name>-T0</Name>
|
||||
</SetRegEntry>
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
<Key>UL2CM3</Key>
|
||||
<Name>UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32F10x_128 -FS08000000 -FL020000 -FP0($$Device:STM32F103RB$Flash\STM32F10x_128.FLM))</Name>
|
||||
</SetRegEntry>
|
||||
</TargetDriverDllRegistry>
|
||||
<Breakpoint>
|
||||
<Bp>
|
||||
<Number>0</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>38</LineNumber>
|
||||
<EnabledFlag>1</EnabledFlag>
|
||||
<Address>134221140</Address>
|
||||
<ByteObject>0</ByteObject>
|
||||
<HtxType>0</HtxType>
|
||||
<ManyObjects>0</ManyObjects>
|
||||
<SizeOfObject>0</SizeOfObject>
|
||||
<BreakByAccess>0</BreakByAccess>
|
||||
<BreakIfRCount>1</BreakIfRCount>
|
||||
<Filename>U:\git\BE_VOILIER\Application\principal.c</Filename>
|
||||
<ExecCommand></ExecCommand>
|
||||
<Expression>\\ProjetVide\../../BE_VOILIER/Application/principal.c\38</Expression>
|
||||
</Bp>
|
||||
<Bp>
|
||||
<Number>1</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>19</LineNumber>
|
||||
<EnabledFlag>1</EnabledFlag>
|
||||
<Address>134221104</Address>
|
||||
<ByteObject>0</ByteObject>
|
||||
<HtxType>0</HtxType>
|
||||
<ManyObjects>0</ManyObjects>
|
||||
<SizeOfObject>0</SizeOfObject>
|
||||
<BreakByAccess>0</BreakByAccess>
|
||||
<BreakIfRCount>1</BreakIfRCount>
|
||||
<Filename>U:\git\BE_VOILIER\Application\principal.c</Filename>
|
||||
<ExecCommand></ExecCommand>
|
||||
<Expression>\\ProjetVide\../../BE_VOILIER/Application/principal.c\19</Expression>
|
||||
</Bp>
|
||||
</Breakpoint>
|
||||
<WatchWindow1>
|
||||
<Ww>
|
||||
<count>0</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>dutyCycle</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>1</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>CCR_VAL</ItemText>
|
||||
</Ww>
|
||||
</WatchWindow1>
|
||||
<Tracepoint>
|
||||
<THDelay>0</THDelay>
|
||||
</Tracepoint>
|
||||
<DebugFlag>
|
||||
<trace>0</trace>
|
||||
<periodic>1</periodic>
|
||||
<aLwin>1</aLwin>
|
||||
<aCover>0</aCover>
|
||||
<aSer1>0</aSer1>
|
||||
<aSer2>0</aSer2>
|
||||
<aPa>0</aPa>
|
||||
<viewmode>1</viewmode>
|
||||
<vrSel>0</vrSel>
|
||||
<aSym>0</aSym>
|
||||
<aTbox>0</aTbox>
|
||||
<AscS1>0</AscS1>
|
||||
<AscS2>0</AscS2>
|
||||
<AscS3>0</AscS3>
|
||||
<aSer3>0</aSer3>
|
||||
<eProf>0</eProf>
|
||||
<aLa>1</aLa>
|
||||
<aPa1>0</aPa1>
|
||||
<AscS4>0</AscS4>
|
||||
<aSer4>0</aSer4>
|
||||
<StkLoc>0</StkLoc>
|
||||
<TrcWin>0</TrcWin>
|
||||
<newCpu>0</newCpu>
|
||||
<uProt>0</uProt>
|
||||
</DebugFlag>
|
||||
<LintExecutable></LintExecutable>
|
||||
<LintConfigFile></LintConfigFile>
|
||||
<bLintAuto>0</bLintAuto>
|
||||
<bAutoGenD>0</bAutoGenD>
|
||||
<LntExFlags>0</LntExFlags>
|
||||
<pMisraName></pMisraName>
|
||||
<pszMrule></pszMrule>
|
||||
<pSingCmds></pSingCmds>
|
||||
<pMultCmds></pMultCmds>
|
||||
<pMisraNamep></pMisraNamep>
|
||||
<pszMrulep></pszMrulep>
|
||||
<pSingCmdsp></pSingCmdsp>
|
||||
<pMultCmdsp></pMultCmdsp>
|
||||
<LogicAnalyzers>
|
||||
<Wi>
|
||||
<IntNumber>0</IntNumber>
|
||||
<FirstString>((PORTB & 0x00000100) >> 8 & 0x100) >> 8</FirstString>
|
||||
<SecondString>FF000000000000000000000000000000E0FFEF400100000000000000000000000000000028504F5254422026203078303030303031303029203E3E2038000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000001000000000000000000F03F1300000000000000000000000000000000000000200F0008</SecondString>
|
||||
</Wi>
|
||||
</LogicAnalyzers>
|
||||
<DebugDescription>
|
||||
<Enable>1</Enable>
|
||||
<EnableFlashSeq>1</EnableFlashSeq>
|
||||
<EnableLog>0</EnableLog>
|
||||
<Protocol>2</Protocol>
|
||||
<DbgClock>10000000</DbgClock>
|
||||
</DebugDescription>
|
||||
</TargetOption>
|
||||
</Target>
|
||||
|
||||
<Group>
|
||||
<GroupName>Application</GroupName>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>1</GroupNumber>
|
||||
<FileNumber>1</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\Application\principal.c</PathWithFileName>
|
||||
<FilenameWithoutPath>principal.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
</Group>
|
||||
|
||||
<Group>
|
||||
<GroupName>Services</GroupName>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>2</GroupNumber>
|
||||
<FileNumber>2</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\src\Servo.c</PathWithFileName>
|
||||
<FilenameWithoutPath>Servo.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>2</GroupNumber>
|
||||
<FileNumber>3</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\Services\Source\Girouette.c</PathWithFileName>
|
||||
<FilenameWithoutPath>Girouette.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>2</GroupNumber>
|
||||
<FileNumber>4</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\Services\Source\Accelerometre.c</PathWithFileName>
|
||||
<FilenameWithoutPath>Accelerometre.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>2</GroupNumber>
|
||||
<FileNumber>5</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\Pilotes\Source\MyUart.c</PathWithFileName>
|
||||
<FilenameWithoutPath>MyUart.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
</Group>
|
||||
|
||||
<Group>
|
||||
<GroupName>Drivers</GroupName>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>6</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\src\ADC.c</PathWithFileName>
|
||||
<FilenameWithoutPath>ADC.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>7</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\src\DriverGPIO.c</PathWithFileName>
|
||||
<FilenameWithoutPath>DriverGPIO.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>8</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\src\Horloge.c</PathWithFileName>
|
||||
<FilenameWithoutPath>Horloge.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>9</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\src\MYGPIO.c</PathWithFileName>
|
||||
<FilenameWithoutPath>MYGPIO.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>10</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\src\MyTimer.c</PathWithFileName>
|
||||
<FilenameWithoutPath>MyTimer.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>11</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\src\PWM.c</PathWithFileName>
|
||||
<FilenameWithoutPath>PWM.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>12</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\src\Timer.c</PathWithFileName>
|
||||
<FilenameWithoutPath>Timer.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>13</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\Pilotes\Source\Plateau.c</PathWithFileName>
|
||||
<FilenameWithoutPath>Plateau.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
</Group>
|
||||
|
||||
<Group>
|
||||
<GroupName>New Group</GroupName>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>4</GroupNumber>
|
||||
<FileNumber>14</FileNumber>
|
||||
<FileType>4</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\BE_VOILIER\Objects\Lib_Com_Periph_2022.lib</PathWithFileName>
|
||||
<FilenameWithoutPath>Lib_Com_Periph_2022.lib</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
</Group>
|
||||
|
||||
<Group>
|
||||
<GroupName>::CMSIS</GroupName>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>1</RteFlg>
|
||||
</Group>
|
||||
|
||||
<Group>
|
||||
<GroupName>::Device</GroupName>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>1</RteFlg>
|
||||
</Group>
|
||||
|
||||
</ProjectOpt>
|
||||
1085
ProjetInitial/Projet0.uvprojx
Executable file
1085
ProjetInitial/Projet0.uvprojx
Executable file
File diff suppressed because it is too large
Load diff
1828
ProjetInitial/RTE/Device/STM32F103RB/RTE_Device.h
Executable file
1828
ProjetInitial/RTE/Device/STM32F103RB/RTE_Device.h
Executable file
File diff suppressed because it is too large
Load diff
1828
ProjetInitial/RTE/Device/STM32F103RB/RTE_Device.h.base@1.1.2
Executable file
1828
ProjetInitial/RTE/Device/STM32F103RB/RTE_Device.h.base@1.1.2
Executable file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,36 @@
|
|||
// File: STM32F101_102_103_105_107.dbgconf
|
||||
// Version: 1.0.0
|
||||
// Note: refer to STM32F101xx STM32F102xx STM32F103xx STM32F105xx STM32F107xx Reference manual (RM0008)
|
||||
// STM32F101xx STM32F102xx STM32F103xx STM32F105xx STM32F107xx datasheets
|
||||
|
||||
// <<< Use Configuration Wizard in Context Menu >>>
|
||||
|
||||
// <h> Debug MCU configuration register (DBGMCU_CR)
|
||||
// <i> Reserved bits must be kept at reset value
|
||||
// <o.30> DBG_TIM11_STOP <i> TIM11 counter stopped when core is halted
|
||||
// <o.29> DBG_TIM10_STOP <i> TIM10 counter stopped when core is halted
|
||||
// <o.28> DBG_TIM9_STOP <i> TIM9 counter stopped when core is halted
|
||||
// <o.27> DBG_TIM14_STOP <i> TIM14 counter stopped when core is halted
|
||||
// <o.26> DBG_TIM13_STOP <i> TIM13 counter stopped when core is halted
|
||||
// <o.25> DBG_TIM12_STOP <i> TIM12 counter stopped when core is halted
|
||||
// <o.21> DBG_CAN2_STOP <i> Debug CAN2 stopped when core is halted
|
||||
// <o.20> DBG_TIM7_STOP <i> TIM7 counter stopped when core is halted
|
||||
// <o.19> DBG_TIM6_STOP <i> TIM6 counter stopped when core is halted
|
||||
// <o.18> DBG_TIM5_STOP <i> TIM5 counter stopped when core is halted
|
||||
// <o.17> DBG_TIM8_STOP <i> TIM8 counter stopped when core is halted
|
||||
// <o.16> DBG_I2C2_SMBUS_TIMEOUT <i> SMBUS timeout mode stopped when core is halted
|
||||
// <o.15> DBG_I2C1_SMBUS_TIMEOUT <i> SMBUS timeout mode stopped when core is halted
|
||||
// <o.14> DBG_CAN1_STOP <i> Debug CAN1 stopped when Core is halted
|
||||
// <o.13> DBG_TIM4_STOP <i> TIM4 counter stopped when core is halted
|
||||
// <o.12> DBG_TIM3_STOP <i> TIM3 counter stopped when core is halted
|
||||
// <o.11> DBG_TIM2_STOP <i> TIM2 counter stopped when core is halted
|
||||
// <o.10> DBG_TIM1_STOP <i> TIM1 counter stopped when core is halted
|
||||
// <o.9> DBG_WWDG_STOP <i> Debug window watchdog stopped when core is halted
|
||||
// <o.8> DBG_IWDG_STOP <i> Debug independent watchdog stopped when core is halted
|
||||
// <o.2> DBG_STANDBY <i> Debug standby mode
|
||||
// <o.1> DBG_STOP <i> Debug stop mode
|
||||
// <o.0> DBG_SLEEP <i> Debug sleep mode
|
||||
// </h>
|
||||
DbgMCU_CR = 0x00000007;
|
||||
|
||||
// <<< end of configuration section >>>
|
||||
308
ProjetInitial/RTE/Device/STM32F103RB/startup_stm32f10x_md.s
Executable file
308
ProjetInitial/RTE/Device/STM32F103RB/startup_stm32f10x_md.s
Executable file
|
|
@ -0,0 +1,308 @@
|
|||
;******************** (C) COPYRIGHT 2011 STMicroelectronics ********************
|
||||
;* File Name : startup_stm32f10x_md.s
|
||||
;* Author : MCD Application Team
|
||||
;* Version : V3.5.1
|
||||
;* Date : 08-September-2021
|
||||
;* Description : STM32F10x Medium Density Devices vector table for MDK-ARM
|
||||
;* toolchain.
|
||||
;* This module performs:
|
||||
;* - Set the initial SP
|
||||
;* - Set the initial PC == Reset_Handler
|
||||
;* - Set the vector table entries with the exceptions ISR address
|
||||
;* - Configure the clock system
|
||||
;* - Branches to __main in the C library (which eventually
|
||||
;* calls main()).
|
||||
;* After Reset the CortexM3 processor is in Thread mode,
|
||||
;* priority is Privileged, and the Stack is set to Main.
|
||||
;* <<< Use Configuration Wizard in Context Menu >>>
|
||||
;*******************************************************************************
|
||||
;*
|
||||
;* Copyright (c) 2011 STMicroelectronics.
|
||||
;* All rights reserved.
|
||||
;*
|
||||
;* This software is licensed under terms that can be found in the LICENSE file
|
||||
;* in the root directory of this software component.
|
||||
;* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
;
|
||||
;*******************************************************************************
|
||||
|
||||
; Amount of memory (in bytes) allocated for Stack
|
||||
; Tailor this value to your application needs
|
||||
; <h> Stack Configuration
|
||||
; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
|
||||
; </h>
|
||||
|
||||
Stack_Size EQU 0x00000400
|
||||
|
||||
AREA STACK, NOINIT, READWRITE, ALIGN=3
|
||||
Stack_Mem SPACE Stack_Size
|
||||
__initial_sp
|
||||
|
||||
|
||||
; <h> Heap Configuration
|
||||
; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
|
||||
; </h>
|
||||
|
||||
Heap_Size EQU 0x00000200
|
||||
|
||||
AREA HEAP, NOINIT, READWRITE, ALIGN=3
|
||||
__heap_base
|
||||
Heap_Mem SPACE Heap_Size
|
||||
__heap_limit
|
||||
|
||||
PRESERVE8
|
||||
THUMB
|
||||
|
||||
|
||||
; Vector Table Mapped to Address 0 at Reset
|
||||
AREA RESET, DATA, READONLY
|
||||
EXPORT __Vectors
|
||||
EXPORT __Vectors_End
|
||||
EXPORT __Vectors_Size
|
||||
|
||||
__Vectors DCD __initial_sp ; Top of Stack
|
||||
DCD Reset_Handler ; Reset Handler
|
||||
DCD NMI_Handler ; NMI Handler
|
||||
DCD HardFault_Handler ; Hard Fault Handler
|
||||
DCD MemManage_Handler ; MPU Fault Handler
|
||||
DCD BusFault_Handler ; Bus Fault Handler
|
||||
DCD UsageFault_Handler ; Usage Fault Handler
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD SVC_Handler ; SVCall Handler
|
||||
DCD DebugMon_Handler ; Debug Monitor Handler
|
||||
DCD 0 ; Reserved
|
||||
DCD PendSV_Handler ; PendSV Handler
|
||||
DCD SysTick_Handler ; SysTick Handler
|
||||
|
||||
; External Interrupts
|
||||
DCD WWDG_IRQHandler ; Window Watchdog
|
||||
DCD PVD_IRQHandler ; PVD through EXTI Line detect
|
||||
DCD TAMPER_IRQHandler ; Tamper
|
||||
DCD RTC_IRQHandler ; RTC
|
||||
DCD FLASH_IRQHandler ; Flash
|
||||
DCD RCC_IRQHandler ; RCC
|
||||
DCD EXTI0_IRQHandler ; EXTI Line 0
|
||||
DCD EXTI1_IRQHandler ; EXTI Line 1
|
||||
DCD EXTI2_IRQHandler ; EXTI Line 2
|
||||
DCD EXTI3_IRQHandler ; EXTI Line 3
|
||||
DCD EXTI4_IRQHandler ; EXTI Line 4
|
||||
DCD DMA1_Channel1_IRQHandler ; DMA1 Channel 1
|
||||
DCD DMA1_Channel2_IRQHandler ; DMA1 Channel 2
|
||||
DCD DMA1_Channel3_IRQHandler ; DMA1 Channel 3
|
||||
DCD DMA1_Channel4_IRQHandler ; DMA1 Channel 4
|
||||
DCD DMA1_Channel5_IRQHandler ; DMA1 Channel 5
|
||||
DCD DMA1_Channel6_IRQHandler ; DMA1 Channel 6
|
||||
DCD DMA1_Channel7_IRQHandler ; DMA1 Channel 7
|
||||
DCD ADC1_2_IRQHandler ; ADC1_2
|
||||
DCD USB_HP_CAN1_TX_IRQHandler ; USB High Priority or CAN1 TX
|
||||
DCD USB_LP_CAN1_RX0_IRQHandler ; USB Low Priority or CAN1 RX0
|
||||
DCD CAN1_RX1_IRQHandler ; CAN1 RX1
|
||||
DCD CAN1_SCE_IRQHandler ; CAN1 SCE
|
||||
DCD EXTI9_5_IRQHandler ; EXTI Line 9..5
|
||||
DCD TIM1_BRK_IRQHandler ; TIM1 Break
|
||||
DCD TIM1_UP_IRQHandler ; TIM1 Update
|
||||
DCD TIM1_TRG_COM_IRQHandler ; TIM1 Trigger and Commutation
|
||||
DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare
|
||||
DCD TIM2_IRQHandler ; TIM2
|
||||
DCD TIM3_IRQHandler ; TIM3
|
||||
DCD TIM4_IRQHandler ; TIM4
|
||||
DCD I2C1_EV_IRQHandler ; I2C1 Event
|
||||
DCD I2C1_ER_IRQHandler ; I2C1 Error
|
||||
DCD I2C2_EV_IRQHandler ; I2C2 Event
|
||||
DCD I2C2_ER_IRQHandler ; I2C2 Error
|
||||
DCD SPI1_IRQHandler ; SPI1
|
||||
DCD SPI2_IRQHandler ; SPI2
|
||||
DCD USART1_IRQHandler ; USART1
|
||||
DCD USART2_IRQHandler ; USART2
|
||||
DCD USART3_IRQHandler ; USART3
|
||||
DCD EXTI15_10_IRQHandler ; EXTI Line 15..10
|
||||
DCD RTCAlarm_IRQHandler ; RTC Alarm through EXTI Line
|
||||
DCD USBWakeUp_IRQHandler ; USB Wakeup from suspend
|
||||
__Vectors_End
|
||||
|
||||
__Vectors_Size EQU __Vectors_End - __Vectors
|
||||
|
||||
AREA |.text|, CODE, READONLY
|
||||
|
||||
; Reset handler
|
||||
Reset_Handler PROC
|
||||
EXPORT Reset_Handler [WEAK]
|
||||
IMPORT __main
|
||||
IMPORT SystemInit
|
||||
LDR R0, =SystemInit
|
||||
BLX R0
|
||||
LDR R0, =__main
|
||||
BX R0
|
||||
ENDP
|
||||
|
||||
; Dummy Exception Handlers (infinite loops which can be modified)
|
||||
|
||||
NMI_Handler PROC
|
||||
EXPORT NMI_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
HardFault_Handler\
|
||||
PROC
|
||||
EXPORT HardFault_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
MemManage_Handler\
|
||||
PROC
|
||||
EXPORT MemManage_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
BusFault_Handler\
|
||||
PROC
|
||||
EXPORT BusFault_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
UsageFault_Handler\
|
||||
PROC
|
||||
EXPORT UsageFault_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
SVC_Handler PROC
|
||||
EXPORT SVC_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
DebugMon_Handler\
|
||||
PROC
|
||||
EXPORT DebugMon_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
PendSV_Handler PROC
|
||||
EXPORT PendSV_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
SysTick_Handler PROC
|
||||
EXPORT SysTick_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
|
||||
Default_Handler PROC
|
||||
|
||||
EXPORT WWDG_IRQHandler [WEAK]
|
||||
EXPORT PVD_IRQHandler [WEAK]
|
||||
EXPORT TAMPER_IRQHandler [WEAK]
|
||||
EXPORT RTC_IRQHandler [WEAK]
|
||||
EXPORT FLASH_IRQHandler [WEAK]
|
||||
EXPORT RCC_IRQHandler [WEAK]
|
||||
EXPORT EXTI0_IRQHandler [WEAK]
|
||||
EXPORT EXTI1_IRQHandler [WEAK]
|
||||
EXPORT EXTI2_IRQHandler [WEAK]
|
||||
EXPORT EXTI3_IRQHandler [WEAK]
|
||||
EXPORT EXTI4_IRQHandler [WEAK]
|
||||
EXPORT DMA1_Channel1_IRQHandler [WEAK]
|
||||
EXPORT DMA1_Channel2_IRQHandler [WEAK]
|
||||
EXPORT DMA1_Channel3_IRQHandler [WEAK]
|
||||
EXPORT DMA1_Channel4_IRQHandler [WEAK]
|
||||
EXPORT DMA1_Channel5_IRQHandler [WEAK]
|
||||
EXPORT DMA1_Channel6_IRQHandler [WEAK]
|
||||
EXPORT DMA1_Channel7_IRQHandler [WEAK]
|
||||
EXPORT ADC1_2_IRQHandler [WEAK]
|
||||
EXPORT USB_HP_CAN1_TX_IRQHandler [WEAK]
|
||||
EXPORT USB_LP_CAN1_RX0_IRQHandler [WEAK]
|
||||
EXPORT CAN1_RX1_IRQHandler [WEAK]
|
||||
EXPORT CAN1_SCE_IRQHandler [WEAK]
|
||||
EXPORT EXTI9_5_IRQHandler [WEAK]
|
||||
EXPORT TIM1_BRK_IRQHandler [WEAK]
|
||||
EXPORT TIM1_UP_IRQHandler [WEAK]
|
||||
EXPORT TIM1_TRG_COM_IRQHandler [WEAK]
|
||||
EXPORT TIM1_CC_IRQHandler [WEAK]
|
||||
EXPORT TIM2_IRQHandler [WEAK]
|
||||
EXPORT TIM3_IRQHandler [WEAK]
|
||||
EXPORT TIM4_IRQHandler [WEAK]
|
||||
EXPORT I2C1_EV_IRQHandler [WEAK]
|
||||
EXPORT I2C1_ER_IRQHandler [WEAK]
|
||||
EXPORT I2C2_EV_IRQHandler [WEAK]
|
||||
EXPORT I2C2_ER_IRQHandler [WEAK]
|
||||
EXPORT SPI1_IRQHandler [WEAK]
|
||||
EXPORT SPI2_IRQHandler [WEAK]
|
||||
EXPORT USART1_IRQHandler [WEAK]
|
||||
EXPORT USART2_IRQHandler [WEAK]
|
||||
EXPORT USART3_IRQHandler [WEAK]
|
||||
EXPORT EXTI15_10_IRQHandler [WEAK]
|
||||
EXPORT RTCAlarm_IRQHandler [WEAK]
|
||||
EXPORT USBWakeUp_IRQHandler [WEAK]
|
||||
|
||||
WWDG_IRQHandler
|
||||
PVD_IRQHandler
|
||||
TAMPER_IRQHandler
|
||||
RTC_IRQHandler
|
||||
FLASH_IRQHandler
|
||||
RCC_IRQHandler
|
||||
EXTI0_IRQHandler
|
||||
EXTI1_IRQHandler
|
||||
EXTI2_IRQHandler
|
||||
EXTI3_IRQHandler
|
||||
EXTI4_IRQHandler
|
||||
DMA1_Channel1_IRQHandler
|
||||
DMA1_Channel2_IRQHandler
|
||||
DMA1_Channel3_IRQHandler
|
||||
DMA1_Channel4_IRQHandler
|
||||
DMA1_Channel5_IRQHandler
|
||||
DMA1_Channel6_IRQHandler
|
||||
DMA1_Channel7_IRQHandler
|
||||
ADC1_2_IRQHandler
|
||||
USB_HP_CAN1_TX_IRQHandler
|
||||
USB_LP_CAN1_RX0_IRQHandler
|
||||
CAN1_RX1_IRQHandler
|
||||
CAN1_SCE_IRQHandler
|
||||
EXTI9_5_IRQHandler
|
||||
TIM1_BRK_IRQHandler
|
||||
TIM1_UP_IRQHandler
|
||||
TIM1_TRG_COM_IRQHandler
|
||||
TIM1_CC_IRQHandler
|
||||
TIM2_IRQHandler
|
||||
TIM3_IRQHandler
|
||||
TIM4_IRQHandler
|
||||
I2C1_EV_IRQHandler
|
||||
I2C1_ER_IRQHandler
|
||||
I2C2_EV_IRQHandler
|
||||
I2C2_ER_IRQHandler
|
||||
SPI1_IRQHandler
|
||||
SPI2_IRQHandler
|
||||
USART1_IRQHandler
|
||||
USART2_IRQHandler
|
||||
USART3_IRQHandler
|
||||
EXTI15_10_IRQHandler
|
||||
RTCAlarm_IRQHandler
|
||||
USBWakeUp_IRQHandler
|
||||
|
||||
B .
|
||||
|
||||
ENDP
|
||||
|
||||
ALIGN
|
||||
|
||||
;*******************************************************************************
|
||||
; User Stack and Heap initialization
|
||||
;*******************************************************************************
|
||||
IF :DEF:__MICROLIB
|
||||
|
||||
EXPORT __initial_sp
|
||||
EXPORT __heap_base
|
||||
EXPORT __heap_limit
|
||||
|
||||
ELSE
|
||||
|
||||
IMPORT __use_two_region_memory
|
||||
EXPORT __user_initial_stackheap
|
||||
|
||||
__user_initial_stackheap
|
||||
|
||||
LDR R0, = Heap_Mem
|
||||
LDR R1, =(Stack_Mem + Stack_Size)
|
||||
LDR R2, = (Heap_Mem + Heap_Size)
|
||||
LDR R3, = Stack_Mem
|
||||
BX LR
|
||||
|
||||
ALIGN
|
||||
|
||||
ENDIF
|
||||
|
||||
END
|
||||
|
||||
308
ProjetInitial/RTE/Device/STM32F103RB/startup_stm32f10x_md.s.base@1.0.1
Executable file
308
ProjetInitial/RTE/Device/STM32F103RB/startup_stm32f10x_md.s.base@1.0.1
Executable file
|
|
@ -0,0 +1,308 @@
|
|||
;******************** (C) COPYRIGHT 2011 STMicroelectronics ********************
|
||||
;* File Name : startup_stm32f10x_md.s
|
||||
;* Author : MCD Application Team
|
||||
;* Version : V3.5.1
|
||||
;* Date : 08-September-2021
|
||||
;* Description : STM32F10x Medium Density Devices vector table for MDK-ARM
|
||||
;* toolchain.
|
||||
;* This module performs:
|
||||
;* - Set the initial SP
|
||||
;* - Set the initial PC == Reset_Handler
|
||||
;* - Set the vector table entries with the exceptions ISR address
|
||||
;* - Configure the clock system
|
||||
;* - Branches to __main in the C library (which eventually
|
||||
;* calls main()).
|
||||
;* After Reset the CortexM3 processor is in Thread mode,
|
||||
;* priority is Privileged, and the Stack is set to Main.
|
||||
;* <<< Use Configuration Wizard in Context Menu >>>
|
||||
;*******************************************************************************
|
||||
;*
|
||||
;* Copyright (c) 2011 STMicroelectronics.
|
||||
;* All rights reserved.
|
||||
;*
|
||||
;* This software is licensed under terms that can be found in the LICENSE file
|
||||
;* in the root directory of this software component.
|
||||
;* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
;
|
||||
;*******************************************************************************
|
||||
|
||||
; Amount of memory (in bytes) allocated for Stack
|
||||
; Tailor this value to your application needs
|
||||
; <h> Stack Configuration
|
||||
; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
|
||||
; </h>
|
||||
|
||||
Stack_Size EQU 0x00000400
|
||||
|
||||
AREA STACK, NOINIT, READWRITE, ALIGN=3
|
||||
Stack_Mem SPACE Stack_Size
|
||||
__initial_sp
|
||||
|
||||
|
||||
; <h> Heap Configuration
|
||||
; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
|
||||
; </h>
|
||||
|
||||
Heap_Size EQU 0x00000200
|
||||
|
||||
AREA HEAP, NOINIT, READWRITE, ALIGN=3
|
||||
__heap_base
|
||||
Heap_Mem SPACE Heap_Size
|
||||
__heap_limit
|
||||
|
||||
PRESERVE8
|
||||
THUMB
|
||||
|
||||
|
||||
; Vector Table Mapped to Address 0 at Reset
|
||||
AREA RESET, DATA, READONLY
|
||||
EXPORT __Vectors
|
||||
EXPORT __Vectors_End
|
||||
EXPORT __Vectors_Size
|
||||
|
||||
__Vectors DCD __initial_sp ; Top of Stack
|
||||
DCD Reset_Handler ; Reset Handler
|
||||
DCD NMI_Handler ; NMI Handler
|
||||
DCD HardFault_Handler ; Hard Fault Handler
|
||||
DCD MemManage_Handler ; MPU Fault Handler
|
||||
DCD BusFault_Handler ; Bus Fault Handler
|
||||
DCD UsageFault_Handler ; Usage Fault Handler
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD SVC_Handler ; SVCall Handler
|
||||
DCD DebugMon_Handler ; Debug Monitor Handler
|
||||
DCD 0 ; Reserved
|
||||
DCD PendSV_Handler ; PendSV Handler
|
||||
DCD SysTick_Handler ; SysTick Handler
|
||||
|
||||
; External Interrupts
|
||||
DCD WWDG_IRQHandler ; Window Watchdog
|
||||
DCD PVD_IRQHandler ; PVD through EXTI Line detect
|
||||
DCD TAMPER_IRQHandler ; Tamper
|
||||
DCD RTC_IRQHandler ; RTC
|
||||
DCD FLASH_IRQHandler ; Flash
|
||||
DCD RCC_IRQHandler ; RCC
|
||||
DCD EXTI0_IRQHandler ; EXTI Line 0
|
||||
DCD EXTI1_IRQHandler ; EXTI Line 1
|
||||
DCD EXTI2_IRQHandler ; EXTI Line 2
|
||||
DCD EXTI3_IRQHandler ; EXTI Line 3
|
||||
DCD EXTI4_IRQHandler ; EXTI Line 4
|
||||
DCD DMA1_Channel1_IRQHandler ; DMA1 Channel 1
|
||||
DCD DMA1_Channel2_IRQHandler ; DMA1 Channel 2
|
||||
DCD DMA1_Channel3_IRQHandler ; DMA1 Channel 3
|
||||
DCD DMA1_Channel4_IRQHandler ; DMA1 Channel 4
|
||||
DCD DMA1_Channel5_IRQHandler ; DMA1 Channel 5
|
||||
DCD DMA1_Channel6_IRQHandler ; DMA1 Channel 6
|
||||
DCD DMA1_Channel7_IRQHandler ; DMA1 Channel 7
|
||||
DCD ADC1_2_IRQHandler ; ADC1_2
|
||||
DCD USB_HP_CAN1_TX_IRQHandler ; USB High Priority or CAN1 TX
|
||||
DCD USB_LP_CAN1_RX0_IRQHandler ; USB Low Priority or CAN1 RX0
|
||||
DCD CAN1_RX1_IRQHandler ; CAN1 RX1
|
||||
DCD CAN1_SCE_IRQHandler ; CAN1 SCE
|
||||
DCD EXTI9_5_IRQHandler ; EXTI Line 9..5
|
||||
DCD TIM1_BRK_IRQHandler ; TIM1 Break
|
||||
DCD TIM1_UP_IRQHandler ; TIM1 Update
|
||||
DCD TIM1_TRG_COM_IRQHandler ; TIM1 Trigger and Commutation
|
||||
DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare
|
||||
DCD TIM2_IRQHandler ; TIM2
|
||||
DCD TIM3_IRQHandler ; TIM3
|
||||
DCD TIM4_IRQHandler ; TIM4
|
||||
DCD I2C1_EV_IRQHandler ; I2C1 Event
|
||||
DCD I2C1_ER_IRQHandler ; I2C1 Error
|
||||
DCD I2C2_EV_IRQHandler ; I2C2 Event
|
||||
DCD I2C2_ER_IRQHandler ; I2C2 Error
|
||||
DCD SPI1_IRQHandler ; SPI1
|
||||
DCD SPI2_IRQHandler ; SPI2
|
||||
DCD USART1_IRQHandler ; USART1
|
||||
DCD USART2_IRQHandler ; USART2
|
||||
DCD USART3_IRQHandler ; USART3
|
||||
DCD EXTI15_10_IRQHandler ; EXTI Line 15..10
|
||||
DCD RTCAlarm_IRQHandler ; RTC Alarm through EXTI Line
|
||||
DCD USBWakeUp_IRQHandler ; USB Wakeup from suspend
|
||||
__Vectors_End
|
||||
|
||||
__Vectors_Size EQU __Vectors_End - __Vectors
|
||||
|
||||
AREA |.text|, CODE, READONLY
|
||||
|
||||
; Reset handler
|
||||
Reset_Handler PROC
|
||||
EXPORT Reset_Handler [WEAK]
|
||||
IMPORT __main
|
||||
IMPORT SystemInit
|
||||
LDR R0, =SystemInit
|
||||
BLX R0
|
||||
LDR R0, =__main
|
||||
BX R0
|
||||
ENDP
|
||||
|
||||
; Dummy Exception Handlers (infinite loops which can be modified)
|
||||
|
||||
NMI_Handler PROC
|
||||
EXPORT NMI_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
HardFault_Handler\
|
||||
PROC
|
||||
EXPORT HardFault_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
MemManage_Handler\
|
||||
PROC
|
||||
EXPORT MemManage_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
BusFault_Handler\
|
||||
PROC
|
||||
EXPORT BusFault_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
UsageFault_Handler\
|
||||
PROC
|
||||
EXPORT UsageFault_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
SVC_Handler PROC
|
||||
EXPORT SVC_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
DebugMon_Handler\
|
||||
PROC
|
||||
EXPORT DebugMon_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
PendSV_Handler PROC
|
||||
EXPORT PendSV_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
SysTick_Handler PROC
|
||||
EXPORT SysTick_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
|
||||
Default_Handler PROC
|
||||
|
||||
EXPORT WWDG_IRQHandler [WEAK]
|
||||
EXPORT PVD_IRQHandler [WEAK]
|
||||
EXPORT TAMPER_IRQHandler [WEAK]
|
||||
EXPORT RTC_IRQHandler [WEAK]
|
||||
EXPORT FLASH_IRQHandler [WEAK]
|
||||
EXPORT RCC_IRQHandler [WEAK]
|
||||
EXPORT EXTI0_IRQHandler [WEAK]
|
||||
EXPORT EXTI1_IRQHandler [WEAK]
|
||||
EXPORT EXTI2_IRQHandler [WEAK]
|
||||
EXPORT EXTI3_IRQHandler [WEAK]
|
||||
EXPORT EXTI4_IRQHandler [WEAK]
|
||||
EXPORT DMA1_Channel1_IRQHandler [WEAK]
|
||||
EXPORT DMA1_Channel2_IRQHandler [WEAK]
|
||||
EXPORT DMA1_Channel3_IRQHandler [WEAK]
|
||||
EXPORT DMA1_Channel4_IRQHandler [WEAK]
|
||||
EXPORT DMA1_Channel5_IRQHandler [WEAK]
|
||||
EXPORT DMA1_Channel6_IRQHandler [WEAK]
|
||||
EXPORT DMA1_Channel7_IRQHandler [WEAK]
|
||||
EXPORT ADC1_2_IRQHandler [WEAK]
|
||||
EXPORT USB_HP_CAN1_TX_IRQHandler [WEAK]
|
||||
EXPORT USB_LP_CAN1_RX0_IRQHandler [WEAK]
|
||||
EXPORT CAN1_RX1_IRQHandler [WEAK]
|
||||
EXPORT CAN1_SCE_IRQHandler [WEAK]
|
||||
EXPORT EXTI9_5_IRQHandler [WEAK]
|
||||
EXPORT TIM1_BRK_IRQHandler [WEAK]
|
||||
EXPORT TIM1_UP_IRQHandler [WEAK]
|
||||
EXPORT TIM1_TRG_COM_IRQHandler [WEAK]
|
||||
EXPORT TIM1_CC_IRQHandler [WEAK]
|
||||
EXPORT TIM2_IRQHandler [WEAK]
|
||||
EXPORT TIM3_IRQHandler [WEAK]
|
||||
EXPORT TIM4_IRQHandler [WEAK]
|
||||
EXPORT I2C1_EV_IRQHandler [WEAK]
|
||||
EXPORT I2C1_ER_IRQHandler [WEAK]
|
||||
EXPORT I2C2_EV_IRQHandler [WEAK]
|
||||
EXPORT I2C2_ER_IRQHandler [WEAK]
|
||||
EXPORT SPI1_IRQHandler [WEAK]
|
||||
EXPORT SPI2_IRQHandler [WEAK]
|
||||
EXPORT USART1_IRQHandler [WEAK]
|
||||
EXPORT USART2_IRQHandler [WEAK]
|
||||
EXPORT USART3_IRQHandler [WEAK]
|
||||
EXPORT EXTI15_10_IRQHandler [WEAK]
|
||||
EXPORT RTCAlarm_IRQHandler [WEAK]
|
||||
EXPORT USBWakeUp_IRQHandler [WEAK]
|
||||
|
||||
WWDG_IRQHandler
|
||||
PVD_IRQHandler
|
||||
TAMPER_IRQHandler
|
||||
RTC_IRQHandler
|
||||
FLASH_IRQHandler
|
||||
RCC_IRQHandler
|
||||
EXTI0_IRQHandler
|
||||
EXTI1_IRQHandler
|
||||
EXTI2_IRQHandler
|
||||
EXTI3_IRQHandler
|
||||
EXTI4_IRQHandler
|
||||
DMA1_Channel1_IRQHandler
|
||||
DMA1_Channel2_IRQHandler
|
||||
DMA1_Channel3_IRQHandler
|
||||
DMA1_Channel4_IRQHandler
|
||||
DMA1_Channel5_IRQHandler
|
||||
DMA1_Channel6_IRQHandler
|
||||
DMA1_Channel7_IRQHandler
|
||||
ADC1_2_IRQHandler
|
||||
USB_HP_CAN1_TX_IRQHandler
|
||||
USB_LP_CAN1_RX0_IRQHandler
|
||||
CAN1_RX1_IRQHandler
|
||||
CAN1_SCE_IRQHandler
|
||||
EXTI9_5_IRQHandler
|
||||
TIM1_BRK_IRQHandler
|
||||
TIM1_UP_IRQHandler
|
||||
TIM1_TRG_COM_IRQHandler
|
||||
TIM1_CC_IRQHandler
|
||||
TIM2_IRQHandler
|
||||
TIM3_IRQHandler
|
||||
TIM4_IRQHandler
|
||||
I2C1_EV_IRQHandler
|
||||
I2C1_ER_IRQHandler
|
||||
I2C2_EV_IRQHandler
|
||||
I2C2_ER_IRQHandler
|
||||
SPI1_IRQHandler
|
||||
SPI2_IRQHandler
|
||||
USART1_IRQHandler
|
||||
USART2_IRQHandler
|
||||
USART3_IRQHandler
|
||||
EXTI15_10_IRQHandler
|
||||
RTCAlarm_IRQHandler
|
||||
USBWakeUp_IRQHandler
|
||||
|
||||
B .
|
||||
|
||||
ENDP
|
||||
|
||||
ALIGN
|
||||
|
||||
;*******************************************************************************
|
||||
; User Stack and Heap initialization
|
||||
;*******************************************************************************
|
||||
IF :DEF:__MICROLIB
|
||||
|
||||
EXPORT __initial_sp
|
||||
EXPORT __heap_base
|
||||
EXPORT __heap_limit
|
||||
|
||||
ELSE
|
||||
|
||||
IMPORT __use_two_region_memory
|
||||
EXPORT __user_initial_stackheap
|
||||
|
||||
__user_initial_stackheap
|
||||
|
||||
LDR R0, = Heap_Mem
|
||||
LDR R1, =(Stack_Mem + Stack_Size)
|
||||
LDR R2, = (Heap_Mem + Heap_Size)
|
||||
LDR R3, = Stack_Mem
|
||||
BX LR
|
||||
|
||||
ALIGN
|
||||
|
||||
ENDIF
|
||||
|
||||
END
|
||||
|
||||
1092
ProjetInitial/RTE/Device/STM32F103RB/system_stm32f10x.c
Executable file
1092
ProjetInitial/RTE/Device/STM32F103RB/system_stm32f10x.c
Executable file
File diff suppressed because it is too large
Load diff
1092
ProjetInitial/RTE/Device/STM32F103RB/system_stm32f10x.c.base@1.0.1
Executable file
1092
ProjetInitial/RTE/Device/STM32F103RB/system_stm32f10x.c.base@1.0.1
Executable file
File diff suppressed because it is too large
Load diff
20
ProjetInitial/RTE/_Reel/RTE_Components.h
Executable file
20
ProjetInitial/RTE/_Reel/RTE_Components.h
Executable file
|
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* UVISION generated file: DO NOT EDIT!
|
||||
* Generated by: uVision version 5.42.0.0
|
||||
*
|
||||
* Project: 'Projet0'
|
||||
* Target: 'Reel'
|
||||
*/
|
||||
|
||||
#ifndef RTE_COMPONENTS_H
|
||||
#define RTE_COMPONENTS_H
|
||||
|
||||
|
||||
/*
|
||||
* Define the Device Header File:
|
||||
*/
|
||||
#define CMSIS_device_header "stm32f10x.h"
|
||||
|
||||
|
||||
|
||||
#endif /* RTE_COMPONENTS_H */
|
||||
20
ProjetInitial/RTE/_Simulation/RTE_Components.h
Executable file
20
ProjetInitial/RTE/_Simulation/RTE_Components.h
Executable file
|
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* UVISION generated file: DO NOT EDIT!
|
||||
* Generated by: uVision version 5.42.0.0
|
||||
*
|
||||
* Project: 'Projet0'
|
||||
* Target: 'Simulation'
|
||||
*/
|
||||
|
||||
#ifndef RTE_COMPONENTS_H
|
||||
#define RTE_COMPONENTS_H
|
||||
|
||||
|
||||
/*
|
||||
* Define the Device Header File:
|
||||
*/
|
||||
#define CMSIS_device_header "stm32f10x.h"
|
||||
|
||||
|
||||
|
||||
#endif /* RTE_COMPONENTS_H */
|
||||
21
ProjetInitial/Services/Include/Accelerometre.h
Executable file
21
ProjetInitial/Services/Include/Accelerometre.h
Executable file
|
|
@ -0,0 +1,21 @@
|
|||
#ifndef ACC_H
|
||||
#define ACC_H
|
||||
#include <stm32f10x.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define LONGUEUR_MOY 10
|
||||
#define ANGLE_LIMITE 60 // Angle ou les voiles seront lachés, SE MODIFIE
|
||||
|
||||
//uint16_t moyenne[LONGUEUR_MOY];
|
||||
//uint32_t sum;
|
||||
//uint16_t i;
|
||||
//volatile uint32_t moy; // Volatile pour pouvoir le regarder dans Keil µVision
|
||||
|
||||
void initAccelo(void);
|
||||
void initLacheur(void);
|
||||
uint16_t * RecupAccelo(void);
|
||||
void LacheVoile(int AngelLim, uint16_t moyennen);
|
||||
|
||||
//uint16_t moyenneGlissante();
|
||||
//int actualiserTableau(int i );
|
||||
#endif
|
||||
8
ProjetInitial/Services/Include/Girouette.h
Executable file
8
ProjetInitial/Services/Include/Girouette.h
Executable file
|
|
@ -0,0 +1,8 @@
|
|||
#ifndef _GIROUETTE_H
|
||||
#define _GIROUETTE_H
|
||||
#include "stm32f10x.h"
|
||||
extern void configEncoder(TIM_TypeDef * Timer);
|
||||
extern int angleVent (TIM_TypeDef * Timer);
|
||||
extern int vent2voile(int angle);
|
||||
extern void LocaliserZero(void);
|
||||
#endif
|
||||
7
ProjetInitial/Services/Include/Servo.h
Executable file
7
ProjetInitial/Services/Include/Servo.h
Executable file
|
|
@ -0,0 +1,7 @@
|
|||
#ifndef SERVO_H_
|
||||
#define SERVO_H_
|
||||
#include <stm32f10x.h>
|
||||
void Servo_Moteur(int angle, TIM_TypeDef * Timer, int Channel);
|
||||
extern void initServo(TIM_TypeDef * Timer, int Channel);
|
||||
|
||||
#endif // SERVO_H_
|
||||
74
ProjetInitial/Services/Source/Accelerometre.c
Executable file
74
ProjetInitial/Services/Source/Accelerometre.c
Executable file
|
|
@ -0,0 +1,74 @@
|
|||
#include <stm32f10x.h>
|
||||
#include "Horloge.h"
|
||||
#include "stdlib.h"
|
||||
#include "MySPI.h"
|
||||
#include "stdint.h"
|
||||
#include "Accelerometre.h"
|
||||
#include "Servo.h"
|
||||
|
||||
|
||||
void initAccelo(void) {
|
||||
MySPI_Init(SPI1);
|
||||
// Power_CTL register = 0x2D ? write 0x08 (MEASURE = 1)
|
||||
MySPI_Clear_NSS();
|
||||
MySPI_Send(0x31); // DATA_FORMAT
|
||||
MySPI_Send(0b00001101); // Justify met le MSB à gauche et b0 et b1 donne une resolution de +-2g
|
||||
MySPI_Set_NSS();
|
||||
|
||||
MySPI_Clear_NSS();
|
||||
MySPI_Send(0x2D & 0x3F); // Écriture de l'adresse (pas de bit de read!)
|
||||
MySPI_Send(0x08); // Affectation du bit MEASURE
|
||||
MySPI_Set_NSS();
|
||||
RCC->APB2ENR |= RCC_APB2ENR_IOPBEN; // Activation de l'horloge Utiliser une service pour cela peut-être ???
|
||||
for (volatile int i = 0; i < 10000; i++); // small delay
|
||||
}
|
||||
|
||||
|
||||
uint16_t * RecupAccelo(void) { // Recuperation des donnees de l'accelerometre
|
||||
static uint16_t Messie[3];
|
||||
uint8_t buf[6];
|
||||
MySPI_Clear_NSS();
|
||||
// Lecture multi-octet à partir de 0x32 (X0, X1, Y0, Y1, Z0 et Z1)
|
||||
MySPI_Send(0x80 | 0x40 | 0x32); // On envoie RW MB A5 ... A0 pour recuperer les données
|
||||
for (int i = 0; i < 6; i++) {buf[i] = (uint8_t)MySPI_Read();} // Lecture des 6 registres en séquenciel
|
||||
MySPI_Set_NSS();
|
||||
|
||||
// Conversion des données récupérés en uint16_t
|
||||
Messie[0] = (uint16_t)(buf[1] << 8 | buf[0]); // X
|
||||
Messie[1] = (uint16_t)(buf[3] << 8 | buf[2]); // Y
|
||||
Messie[2] = (uint16_t)(buf[5] << 8 | buf[4]); // Z
|
||||
return Messie;
|
||||
}
|
||||
|
||||
|
||||
void initLacheur(void) {
|
||||
GPIOB->CRH &= ~(0xF << (0 * 4));
|
||||
GPIOB->CRH |= (0xA << (0 * 4)); //On met GPIOB.8 en mode output 2Mhz, alternate pp
|
||||
|
||||
Timer_Init(TIM4, 0xFFFF, 22);
|
||||
}
|
||||
|
||||
|
||||
void LacheVoile(int AngelLim, uint16_t moyennen) {
|
||||
volatile uint16_t Val_lim = 0x1E20 - 60*AngelLim;
|
||||
if (moyennen<Val_lim){
|
||||
Servo_Moteur(0, TIM4, 3); // PB7 (TIM4Ch3)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//int actualiserTableau(int i) {
|
||||
// moyenne[i] = RecupAccelo()[2]; // Récuperation et ajout de la valeur plus récente dans le tableau dans la position i
|
||||
// i++;
|
||||
// if (i >= LONGUEUR_MOY) {i = 0;} // Géstion de la position i dans le tableau pour la moyenne glissante
|
||||
// return i;
|
||||
//}
|
||||
|
||||
|
||||
//uint16_t moyenneGlissante() {
|
||||
// sum = 0;
|
||||
// for (int j = 0; j < LONGUEUR_MOY; j++){sum += moyenne[j];} moy = sum / LONGUEUR_MOY; // Calcul de la moyenne glissante
|
||||
// return(moy);
|
||||
// }
|
||||
// À faire : Gestion par interruption
|
||||
|
||||
63
ProjetInitial/Services/Source/Girouette.c
Executable file
63
ProjetInitial/Services/Source/Girouette.c
Executable file
|
|
@ -0,0 +1,63 @@
|
|||
#include "stm32f10x.h"
|
||||
#include "Horloge.h"
|
||||
#include "DriverGPIO.h"
|
||||
#include "Girouette.h"
|
||||
#include "PWM.h"
|
||||
#include "Servo.h"
|
||||
|
||||
#include <stdlib.h> // Pour abs()
|
||||
|
||||
#define POSITIONS (360*4) //0x5A0
|
||||
|
||||
void configEncoder(TIM_TypeDef * Timer) {
|
||||
// Timer
|
||||
Timer_Init(Timer, 0, 0);
|
||||
|
||||
// Settings
|
||||
Timer -> CCMR1 |= TIM_CCMR1_CC1S; // TI1FP1 mapped on TI1
|
||||
Timer -> CCMR1 |= TIM_CCMR1_CC2S; // TI1FP2 mapped on TI2
|
||||
Timer -> CCER &= ~(TIM_CCER_CC1P | TIM_CCER_CC1NP); // TI1FP1 output non-inverted
|
||||
Timer -> CCMR1 &= ~(TIM_CCMR1_IC1F); // Input capture 1 filter, no filter
|
||||
Timer -> CCER &= ~(TIM_CCER_CC2P | TIM_CCER_CC2NP); // TI1FP2 output non-inverted
|
||||
Timer -> CCMR2 &= ~(TIM_CCMR1_IC2F); // Input capture 2 filter, no filter
|
||||
Timer -> SMCR &= ~TIM_SMCR_SMS; // Reset SMS-bits
|
||||
Timer -> SMCR |= TIM_SMCR_SMS_0 | TIM_SMCR_SMS_1;// SMS = "011"
|
||||
Timer -> CR1 |= TIM_CR1_CEN; // Enable counter
|
||||
Timer -> ARR = 0x5A0; // Setting ARR as 1440
|
||||
|
||||
// GPIO
|
||||
MyGPIO_Init(GPIOA,0,In_Floating ); // GPIOA pin 0 in mode floating TIM2_CH1
|
||||
MyGPIO_Init(GPIOA,1,In_Floating ); // GPIOA pin 1 in mode floating TIM2_CH2
|
||||
MyGPIO_Init(GPIOA,8,In_PullDown ); // GPIOA pin 8 in mode floating Index
|
||||
}
|
||||
|
||||
|
||||
int angleVent(TIM_TypeDef * Timer) { // Returner l'angle du vent
|
||||
int angle =(((Timer -> CNT*360)/POSITIONS ));
|
||||
if (angle > 180){
|
||||
angle = 360 - angle; // Pour que l'angle soit entre 0 et 180
|
||||
}
|
||||
return(angle);
|
||||
}
|
||||
|
||||
|
||||
int vent2voile(int angle) { // Conversion angle vent à angle voile
|
||||
if(angle < 45){
|
||||
return 0;// Les voiles restent immobiles
|
||||
}
|
||||
else{
|
||||
return(2*(angle-45)/3); // Augmentation linéaire
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LocaliserZero(void) { // Localisation de z
|
||||
int Z_trouve = 0;
|
||||
while (Z_trouve != 1){
|
||||
if(MyGPIO_Read(GPIOA,8)){ // Index
|
||||
TIM2 -> CNT = 0x0; // Remet angle à zero
|
||||
Z_trouve = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
13
ProjetInitial/Services/Source/RTC.c
Executable file
13
ProjetInitial/Services/Source/RTC.c
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
#include "RTC.h"
|
||||
|
||||
|
||||
initRTC() {
|
||||
RTC -> PRLL = 0x7FFF; // Obtenir un période de 1 seconde
|
||||
RTC -> PRLH = 0xFFFF; // Le plus grand possible
|
||||
}
|
||||
|
||||
|
||||
int getTime() {
|
||||
return(RTC -> PRLH);
|
||||
}
|
||||
|
||||
29
ProjetInitial/Services/Source/Servo.c
Executable file
29
ProjetInitial/Services/Source/Servo.c
Executable file
|
|
@ -0,0 +1,29 @@
|
|||
#include "Servo.h"
|
||||
#include "DriverGPIO.h"
|
||||
#include "PWM.h"
|
||||
#include "Horloge.h"
|
||||
|
||||
|
||||
void Servo_Moteur(int angle, TIM_TypeDef * Timer, int Channel) { // Controle du moteur
|
||||
int dutyCycle = (5* angle + 5*90)/90; // 5-10 % Duty Cycle
|
||||
Set_DutyCycle_PWM(Timer, Channel, dutyCycle);
|
||||
}
|
||||
|
||||
|
||||
void initServo(TIM_TypeDef * Timer, int Channel) { // Config du moteur servo
|
||||
if (Timer == TIM4) {
|
||||
Timer_Init(TIM4, 0xFFFF, 22); // Pour obtenir un période de 20 ms
|
||||
|
||||
if (Channel == 3){
|
||||
MyGPIO_Init(GPIOB, 8, AltOut_Ppull); // Output push pull alternate
|
||||
MyTimer_PWM(TIM4, 3); // TIM4 CH3 pour PB8
|
||||
}
|
||||
else{
|
||||
//printf("Ce pilote n'existe pas");
|
||||
}
|
||||
}
|
||||
else{
|
||||
//printf("Ce pilote n'existe pas");
|
||||
}
|
||||
}
|
||||
|
||||
8
ProjetInitial/include/ADC.h
Executable file
8
ProjetInitial/include/ADC.h
Executable file
|
|
@ -0,0 +1,8 @@
|
|||
#include <stm32f10x.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define GPIO_ANALOG_INPUT 0
|
||||
|
||||
void initADC();
|
||||
int recupADC(void);
|
||||
void sendinfoADC();
|
||||
17
ProjetInitial/include/DriverGPIO.h
Executable file
17
ProjetInitial/include/DriverGPIO.h
Executable file
|
|
@ -0,0 +1,17 @@
|
|||
#ifndef DRIVERGPIO_H_
|
||||
#define DRIVERGPIO_H_
|
||||
#include "stm32f10x.h"
|
||||
#define In_Floating 0x4
|
||||
#define In_PullDown 0x8
|
||||
#define In_PullUp 0x8
|
||||
#define In_Analog 0x0
|
||||
#define Out_Ppull 0x3
|
||||
#define Out_OD 0x7
|
||||
#define AltOut_Ppull 0xB
|
||||
#define AltOut_OD 0xF
|
||||
extern void MyGPIO_Init(GPIO_TypeDef * GPIO, char pin, char conf );
|
||||
extern int MyGPIO_Read(GPIO_TypeDef * GPIO, char GPIO_Pin); // renvoie 0 ou autre chose different de 0
|
||||
extern void MyGPIO_Set(GPIO_TypeDef * GPIO, char GPIO_Pin);
|
||||
extern void MyGPIO_Reset(GPIO_TypeDef * GPIO, char GPIO_Pin);
|
||||
extern void MyGPIO_Toggle(GPIO_TypeDef * GPIO, char GPIO_Pin);
|
||||
#endif
|
||||
12
ProjetInitial/include/Horloge.h
Executable file
12
ProjetInitial/include/Horloge.h
Executable file
|
|
@ -0,0 +1,12 @@
|
|||
#include <stm32f10x.h>
|
||||
#define PSC_VAL 624
|
||||
#define ARR_VAL 0xE0FF
|
||||
|
||||
//DUTY CYCLE
|
||||
#define DUTYC 70 //Chiffre entre 0 et 100, où 100 est 100% duty cycle
|
||||
#define POWERMODETIMER 1 // 1 vaut powermode 1, 0 vaut powermode 2 (Powermode pour le config de dutycycle)
|
||||
//Powermode 1 reste sur la bonne polarité: cad. si DUTY_CYCLE vaut 60 alors le signal reste HIGH pour 60% du periode, inverse pour pwmd2
|
||||
//Timer
|
||||
void Timer_Init(TIM_TypeDef *Timer, unsigned short Autoreload, unsigned short Prescaler);
|
||||
void MyTimer_ActiveIT(TIM_TypeDef * Timer, char Prio, void(*Interrupt_fonc)(void));
|
||||
void TIM2_IRQHandler(void);
|
||||
38
ProjetInitial/include/MYGPIO.h
Executable file
38
ProjetInitial/include/MYGPIO.h
Executable file
|
|
@ -0,0 +1,38 @@
|
|||
//Definitions
|
||||
|
||||
//INTERNE
|
||||
#define LED_PIN_INTERNE (5) // 5 pour le LED de Arduino
|
||||
#define BUTTON_GPIO_INTERNE (GPIOA) //GPIOA pour l'Arduion
|
||||
#define LED_GPIO_INTERNE (GPIOA) //GPIOA pour Arduino
|
||||
#define BUTTON_PIN_INTERNE (13) //13 pour Arduino
|
||||
|
||||
//EXTERNE
|
||||
#define LED_PIN_EXTERNE (8) // 8 pour la porte PB8
|
||||
#define BUTTON_GPIO_EXTERNE (GPIOB) //GPIOB pour externe
|
||||
#define LED_GPIO_EXTERNE (GPIOB) //GPIOB pour Externe
|
||||
#define BUTTON_PIN_EXTERNE (9) //9 pour bouton poussoir
|
||||
|
||||
//STATIQUES
|
||||
#define GPIO_OUTPUT_PPULL_MODE (2) //Mis en GP output 2MHz en mode PP
|
||||
#define GPIO_INPUT_PUPD_MODE (8) //Pour mettre à Pull up/down
|
||||
#define GPIO_INPUT_FLOATING_MODE (4)
|
||||
|
||||
//si on est sur l'arduino ou sur le led externe
|
||||
#define INTERNE 1 // 1 c'est vrai, 0 faux
|
||||
|
||||
//FONCTIONS
|
||||
void initGPIO_Interne(void);
|
||||
int boutonAppuye_Interne(void);
|
||||
void allumerDEL_Interne(void);
|
||||
void eteindreDEL_Interne(void);
|
||||
void commuterDEL_Interne(void);
|
||||
void allume_bit_Interne(void);
|
||||
|
||||
void initGPIO_Externe(void);
|
||||
int boutonAppuye_Externe(void);
|
||||
void allumerDEL_Externe(void);
|
||||
void eteindreDEL_Externe(void);
|
||||
void commuterDEL_Externe(void);
|
||||
void allume_bit_Externe(void);
|
||||
|
||||
|
||||
229
ProjetInitial/include/MyI2C.h
Executable file
229
ProjetInitial/include/MyI2C.h
Executable file
|
|
@ -0,0 +1,229 @@
|
|||
#ifndef _I2C_
|
||||
#define _I2C_
|
||||
|
||||
#include "stm32f10x.h"
|
||||
|
||||
/*************************************************************************************
|
||||
===================== By Periph team INSA GEI 2022 ===========================
|
||||
*************************************************************************************/
|
||||
|
||||
/*
|
||||
*************************************************************************************
|
||||
===================== I2C les IO STM32F103 =================================
|
||||
*************************************************************************************
|
||||
|
||||
Les IO sont pris en charge par la lib, pas besoin de faire les configurations Alt OD.
|
||||
|
||||
**I2C1**
|
||||
SCL PB6
|
||||
SDA PB7
|
||||
|
||||
**I2C2**
|
||||
SCL PB10
|
||||
SDA PB11
|
||||
|
||||
|
||||
*************************************************************************************
|
||||
==================== Fondamentaux I2C ==========================================
|
||||
*************************************************************************************
|
||||
- Bus synchrone Low speed (<100kHz) ou high speed (=400kHz), Ici Low speed 100kHz.
|
||||
- Transfert octet par octet, poids fort en premier, avec aquittement pour chaque octet
|
||||
- Deux lignes SDA et SCL (horloge) en open drain, repos '1'
|
||||
- bit "normal" = SDA stable lors du pulse SCL (ie durant l'état haut de SCL, SDA est stable)
|
||||
- bit Start/Stop/Restart = SDA non stable lorsque SCL vaut '1' (violation règle précédente)
|
||||
* Start : front descendant de SDA lorsque SCL vaut '1'
|
||||
* Stop : front montant de SDA lorsque SCL = '1'
|
||||
* Restart = Start en cours de trame (typiquement pour changer Write/read).
|
||||
- uC en Mode Master uniquement (c'est notre choix) : c'est le uC qui est maître de l'horloge SCL.
|
||||
- Le Slave a une @ 7 bits. On ajoute un bit LSB qui est /WR (donc 0 pour écriture, 1 pour lecture)
|
||||
- Une adresse s'écrit donc |a6 a5 a4 a3 a2 a1 a0 /WR| ce qui donne 8 bits. Elle indique une future
|
||||
lecture ou écriture.
|
||||
On parle d'@ 7 bits en regroupant |a6 a5 a4 a3 a2 a1 a0|
|
||||
On parle d'@ 8 bits en regroupant |a6 a5 a4 a3 a2 a1 a0 /WR| (donc une @ écriture, une @ lecture)
|
||||
NB : préférer le concept @7bits...c'est plus clair.
|
||||
|
||||
- On peut lire ou écrire une ou plusieurs données à la suite. C'est lors de l'envoie de l'adresse Slave
|
||||
par le Master que le sens à venir pour les datas est indiqué.
|
||||
- En écriture,
|
||||
* les Ack sont faits par le slave après chaque octet envoyé par le master (Ack = mise à 0 le bit 9).
|
||||
- En lecture,
|
||||
* dès que le l@ slave est transmise (/RW = 1), et le Ack réalisé, le slave positionne le bit 7
|
||||
du prochain octet à lire sur SDA par anticipation ,
|
||||
* le master enchaîne ses pulses (9), lors du pulse 9 (le dernier) c'est le master qui acquite.
|
||||
* Après chaque acquitement, le Slave amorce le prochain octet en positionnant son bit 7 sur SDA
|
||||
* Après le dernier octet, le Master génère un stop.
|
||||
* Pour pouvoir générer le stop, le Master doit piloter SDA, or ce n'est pas possible puisque
|
||||
le Slave positionne le futur bit 7 ... Pour régler ce problème :
|
||||
lors du dernier transfert, le Master N'acquitte PAS (NACK). Ainsi le Slave ne
|
||||
propose plus le bit 7 du prochain octet sur SDA et libère SDA. Le Master peut alors clôturer la
|
||||
communication avec un Stop.
|
||||
|
||||
|
||||
|
||||
|
||||
======= Echange typique avec un Slave ================================================================
|
||||
- Une lecture ou écriture se fait vers un Slave et à partir d'une adresse mémoire donnée (pointeur interne).
|
||||
Ce pointeur est automatiquement incrémenté dans le slave lors des accès écriture ou lecture.
|
||||
|
||||
- Ecriture de N octets , trame complète (@ = adresse slave, pt = valeur de chargement du pointeur interne)
|
||||
|Start Cond |@6|@5|@4|@3|@2|@1|@0| Wr =0 |Slave ACK|
|
||||
|pt7|pt6|pt5|pt4|pt3|pt2|pt1|pt0|Slave ACK|
|
||||
|d7|d6|d5|d4|d3|d2|d1|d0|Slave ACK| (data 1)
|
||||
.....
|
||||
|d7|d6|d5|d4|d3|d2|d1|d0|Salve ACK|Stop Cond| (data N)
|
||||
|
||||
- Lecture de N octets à partir d'une adresse de pointeur donnée
|
||||
|Start Cond |@6|@5|@4|@3|@2|@1|@0| Wr =0 |Slave ACK|
|
||||
|pt7|pt6|pt5|pt4|pt3|pt2|pt1|pt0|Slave ACK|
|
||||
|ReStart Cond |@6|@5|@4|@3|@2|@1|@0| Wr =1 |Slave ACK| (NB: restart nécessaire pour changer écriture / lecture)
|
||||
|d7|d6|d5|d4|d3|d2|d1|d0|Master ACK| (data 1)
|
||||
.....
|
||||
|d7|d6|d5|d4|d3|d2|d1|d0|Master ACK| (data N-1)
|
||||
|d7|d6|d5|d4|d3|d2|d1|d0|Master NACK|Stop Cond| (data N)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
*************************************************************************************
|
||||
==================== La lib I2C ==========================================
|
||||
*************************************************************************************
|
||||
|
||||
3 fonctions essentielles :
|
||||
MyI2C_Init
|
||||
MyI2C_PutString
|
||||
MyI2C_GetString
|
||||
|
||||
1 fonction spéciale : MyI2C_Get_Error
|
||||
|
||||
Les fonctions Put/Get string fonctionnent sur le principe classique décrit précédemment
|
||||
(Slave@, Pter @, Data...).
|
||||
La fonction init prend parmi ses paramètres le nom d'une fct callback d'erreur.
|
||||
En fait, le driver gère en IT les erreurs possibles I2C. La fonction MyI2C_Get_Error permet de
|
||||
recevoir un code erreur.
|
||||
Il est conseillé d'utiliser ce callback. Si on tombe dedans, c'est qu'une erreur s'est produite.
|
||||
Si le code erreur est "inconnu", souvent c'est qu'il y a un soucis à l'adressage slave:
|
||||
Vérifier alors la connectique physique SDA/SCL ainsi que l'alimentation du slave ou tout simplement
|
||||
l'@ slave !
|
||||
|
||||
|
||||
==========================================================================================*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*=========================================================================================
|
||||
GESTION ERREURS
|
||||
========================================================================================= */
|
||||
typedef enum
|
||||
{
|
||||
OK,
|
||||
BusError, //
|
||||
AckFail, // Pas,d'ack
|
||||
TimeOut, // SCL est resté plus de 25ms à l'état bas
|
||||
UnknownError // IT erreur déclenchée mais pas de flag explicite ...
|
||||
} MyI2C_Err_Enum;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Retourne les erreurs I2C
|
||||
* @param I2Cx: where x can be 1 or 2 to select the I2C peripheral.
|
||||
* @retval Type d'erreur rencontrée , voir MyI2C_Err_Enum
|
||||
*/
|
||||
|
||||
MyI2C_Err_Enum MyI2C_Get_Error(I2C_TypeDef * I2Cx);
|
||||
|
||||
|
||||
|
||||
/*=========================================================================================
|
||||
INITIALISATION I2C
|
||||
========================================================================================= */
|
||||
|
||||
|
||||
/**
|
||||
* @brief Initialise l'interface I2C (1 ou 2)
|
||||
* @param I2Cx: where x can be 1 or 2 to select the I2C peripheral.
|
||||
* @param char IT_Prio_I2CErr 0 à 15 (utilisé en cas d'erreur, IT courte et non bloquante
|
||||
* @param *ITErr_function : callback à utiliser pour sortir d'un plantage transmission
|
||||
* @retval None
|
||||
* @Example MyI2C_Init(I2C1, 2,My_CallbackErr);
|
||||
|
||||
|
||||
|
||||
*/
|
||||
void MyI2C_Init(I2C_TypeDef * I2Cx, char IT_Prio_I2CErr, void (*ITErr_function) (void));
|
||||
|
||||
|
||||
|
||||
/*=========================================================================================
|
||||
EMISSION I2C : PutString
|
||||
========================================================================================= */
|
||||
|
||||
|
||||
// Structure de données pour l'émission ou la réception I2C :
|
||||
typedef struct
|
||||
{
|
||||
char SlaveAdress7bits; // l'adresse I2C du slave device
|
||||
char * Ptr_Data; // l'adresse du début de tableau char à recevoir/émettre (tableau en RAM uC)
|
||||
char Nb_Data; // le nbre d'octets à envoyer / recevoir
|
||||
}
|
||||
MyI2C_RecSendData_Typedef;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief|Start Cond |@6|@5|@4|@3|@2|@1|@0| Wr =0 |Slave ACK|
|
||||
|pt7|pt6|pt5|pt4|pt3|pt2|pt1|pt0|Slave ACK|
|
||||
|d7|d6|d5|d4|d3|d2|d1|d0|Slave ACK| (data 1)
|
||||
.....
|
||||
|d7|d6|d5|d4|d3|d2|d1|d0|Salve ACK|Stop Cond| (data N)
|
||||
|
||||
* @param I2Cx: where x can be 1 or 2 to select the I2C peripheral.
|
||||
* @param PteurAdress = adresse de démarrage écriture à l'interieur du slave I2C
|
||||
* @param DataToSend, adresse de la structure qui contient les informations à transmettre
|
||||
voir définition MyI2C_RecSendData_Typedef
|
||||
* @retval None
|
||||
* @Example MyI2C_PutString(I2C1,0xAA, &MyI2C_SendTimeData);
|
||||
* Ecrit dans le slave câblé sur I2C1 à partir de l'@ mémoire interne Slave 0xAA
|
||||
|
||||
*/
|
||||
void MyI2C_PutString(I2C_TypeDef * I2Cx, char PteurAdress, MyI2C_RecSendData_Typedef * DataToSend);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*=========================================================================================
|
||||
Réception I2C : GetString
|
||||
========================================================================================= */
|
||||
|
||||
/**
|
||||
* @brief |Start Cond |@6|@5|@4|@3|@2|@1|@0| Wr =0 |Slave ACK|
|
||||
|pt7|pt6|pt5|pt4|pt3|pt2|pt1|pt0|Slave ACK|
|
||||
|ReStart Cond |@6|@5|@4|@3|@2|@1|@0| Wr =1 |Slave ACK|
|
||||
|d7|d6|d5|d4|d3|d2|d1|d0|Master ACK| (data 1)
|
||||
.....
|
||||
|d7|d6|d5|d4|d3|d2|d1|d0|Master NACK|Stop Cond| (data N)
|
||||
|
||||
* @param I2Cx: where x can be 1 or 2 to select the I2C peripheral.
|
||||
* @param PteurAdress = adresse de démarrage lecture à l'interieur du slave I2C
|
||||
* @param DataToSend, adresse de la structure qui contient les informations nécessaires à la
|
||||
réception des données voir définition MyI2C_RecSendData_Typedef
|
||||
* @retval None
|
||||
* @Example MyI2C_GetString(I2C1,0xAA, &MyI2C_RecevievedTimeData);
|
||||
Lit dans le slave câblé sur I2C1 à partir de l'@ mémoire interne Slave 0xAA
|
||||
*/
|
||||
void MyI2C_GetString(I2C_TypeDef * I2Cx, char PteurAdress, MyI2C_RecSendData_Typedef * DataToReceive);
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
129
ProjetInitial/include/MySPI.h
Executable file
129
ProjetInitial/include/MySPI.h
Executable file
|
|
@ -0,0 +1,129 @@
|
|||
|
||||
#ifndef INC_MYSPI_H_
|
||||
#define INC_MYSPI_H_
|
||||
|
||||
#include "stm32f10x.h"
|
||||
|
||||
/*************************************************************************************
|
||||
===================== By Periph team INSA GEI 2022 ===========================
|
||||
*************************************************************************************/
|
||||
|
||||
/*
|
||||
*************************************************************************************
|
||||
===================== I2C les IO STM32F103 =================================
|
||||
*************************************************************************************
|
||||
Les IO sont pris en charge par la lib, pas besoin de faire les configurations
|
||||
|
||||
|
||||
Sur la Nucléo , le SPI1 est perturbé par la LED2 (PA5), mais doit pouvoir subir les front SCK qd même (LED clignote vite..)
|
||||
le SPI2 n'est pas utilisable car pin non connectées par défaut (sauf à modifier les SB). En fait la Nucléo fait un choix entre SPI1
|
||||
et SPI2 par soudage jumper (SB).
|
||||
|
||||
-> Utiliser SPI1 avec la carte Nucléo
|
||||
|
||||
* **IO SPI 1**
|
||||
SPI1_NSS PA4
|
||||
SPI1_SCK PA5
|
||||
SPI1_MISO PA6
|
||||
SPI1_MOSI PA7
|
||||
|
||||
**IO SPI 2**
|
||||
SPI2_NSS PB12
|
||||
SPI2_SCK PB13
|
||||
SPI2_MISO PB14
|
||||
SPI2_MOSI PB15
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
*************************************************************************************
|
||||
==================== Fondamentaux SPI ==========================================
|
||||
*************************************************************************************
|
||||
- Bus Synchrone, 4 fils (même si on peut l'utiliser en 3 fils)
|
||||
- Transfert à l'octet
|
||||
- Protocole entre un Master (contrôle SCK) et un Slave
|
||||
- SCK permet de synchroniser les bits de chaque octet. Il se configure par :
|
||||
* son niveau de repos : ici niveau '1'
|
||||
* le front actif de synchronisation pour chaque bit : ici front montant (front up durant bit stable)
|
||||
- /CS ou /NSS active le slave sur l'état bas
|
||||
- MOSI : Master Out Slave In (donc data circulant du Master vers le Slave, donc écriture dans le Slave)
|
||||
- MISO : Master In Slave Out (donc data circulant du Slave vers le Master, donc lecture du Slave)
|
||||
|
||||
Bien que la lib propose une fonction d'écriture et de lecture :
|
||||
* une écriture s'accompagne obligatoirement d'une lecture (bidon)
|
||||
* une lecture s'accompagne obligatoirement d'une écriture (bidon)
|
||||
La gestion /CS = /NSS se fait "à la main". On peut alors lire toute une série d'octets
|
||||
en laissant /CS à l'état bas pendant toute la durée de circulation des octets.
|
||||
|
||||
|
||||
*************************************************************************************
|
||||
==================== La lib SPI ==========================================
|
||||
*************************************************************************************
|
||||
|
||||
fonctions essentielles :
|
||||
|
||||
MySPI_Init
|
||||
MySPI_Send
|
||||
MySPI_Read
|
||||
MySPI_Set_NSS
|
||||
MySPI_Clear_NSS
|
||||
|
||||
|
||||
==========================================================================================*/
|
||||
|
||||
|
||||
|
||||
|
||||
/*=========================================================================================
|
||||
INITIALISATION SPI
|
||||
========================================================================================= */
|
||||
|
||||
/**
|
||||
* @brief Configure le SPI spécifié : FSCK = 281kHz, Repos SCK = '1', Front actif = up
|
||||
Gestion /CS logicielle à part, configure les 4 IO
|
||||
- SCK, MOSI : Out Alt push pull
|
||||
- MISO : floating input
|
||||
- /NSS (/CS) : Out push pull
|
||||
* @param SPI_TypeDef * SPI : SPI1 ou SPI2
|
||||
*/
|
||||
void MySPI_Init(SPI_TypeDef * SPI);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Envoie un octet (/CS non géré, à faire logiciellement)
|
||||
Plus en détail, émission de l'octet souhaité sur MOSI
|
||||
Lecture en même temps d'un octet poubelle sur MISO (non exploité)
|
||||
* @param : char ByteToSend : l'octet à envoyer
|
||||
*/
|
||||
void MySPI_Send(char ByteToSend);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Reçoit un octet (/CS non géré, à faire logiciellement)
|
||||
Plus en détail, émission d'un octet bidon sur MOSI (0x00)
|
||||
pour élaborer les 8 fronts sur SCK et donc piloter le slave en lecture
|
||||
qui répond sur MISO
|
||||
* @param : none
|
||||
* @retval : l'octet lu.
|
||||
*/
|
||||
char MySPI_Read(void);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Positionne /CS = /NSS à '1'. A utiliser pour borner les octets à transmettre/recevoir
|
||||
* @param : none
|
||||
*/
|
||||
void MySPI_Set_NSS(void);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Positionne /CS = /NSS à '0'. A utiliser pour borner les octets à transmettre/recevoir
|
||||
* @param :none
|
||||
*/
|
||||
void MySPI_Clear_NSS(void);
|
||||
|
||||
#endif
|
||||
12
ProjetInitial/include/MyTimer.h
Executable file
12
ProjetInitial/include/MyTimer.h
Executable file
|
|
@ -0,0 +1,12 @@
|
|||
#include "stm32f10x.h"
|
||||
|
||||
//TIMERS start
|
||||
#define MyTimer_Base_Start(Timer) (Timer->CR1 |= TIM_CR1_CEN)
|
||||
#define MyTimer_Base_Stop(Timer) (Timer -> CR1 =(0x0))
|
||||
// IT
|
||||
extern volatile int g_tick_count; // Declara que a variável existe em outro arquivo
|
||||
void Test(void);
|
||||
void ConfigureIT();
|
||||
// PWM
|
||||
void ConfigurePWM();
|
||||
void ConfigureTimers();
|
||||
10
ProjetInitial/include/PWM.h
Executable file
10
ProjetInitial/include/PWM.h
Executable file
|
|
@ -0,0 +1,10 @@
|
|||
#ifndef PWM_H_
|
||||
#define PWM_H_
|
||||
#include <stm32f10x.h>
|
||||
//Variables
|
||||
#define POWERMODE 2 // 1 vaut powermode 1, 0 vaut powermode 2 (Powermode pour le config de dutycycle)
|
||||
// Config
|
||||
extern void MyTimer_PWM(TIM_TypeDef * Timer , int Channel);
|
||||
extern int Set_DutyCycle_PWM(TIM_TypeDef *Timer, int Channel, int DutyC);
|
||||
int Set_DutyCycle_PWM_Plateau(TIM_TypeDef *Timer, int Channel, int DutyC);
|
||||
#endif
|
||||
7
ProjetInitial/include/Servo.h
Executable file
7
ProjetInitial/include/Servo.h
Executable file
|
|
@ -0,0 +1,7 @@
|
|||
#ifndef SERVO_H_
|
||||
#define SERVO_H_
|
||||
#include <stm32f10x.h>
|
||||
void Servo_Moteur(int angle, TIM_TypeDef * Timer, int Channel);
|
||||
extern void initServo(TIM_TypeDef * Timer, int Channel);
|
||||
|
||||
#endif // SERVO_H_
|
||||
8
ProjetInitial/include/Timer.h
Executable file
8
ProjetInitial/include/Timer.h
Executable file
|
|
@ -0,0 +1,8 @@
|
|||
#ifndef TIMER_H_
|
||||
#define TIMER_H_
|
||||
#include <stm32f10x.h>
|
||||
// Config de timer
|
||||
extern void MyTimer_Base_Init(TIM_TypeDef *Timer , unsigned short ValARR , unsigned short ValPSC );
|
||||
// Enable timers
|
||||
void EnableTimer(TIM_TypeDef *Timer);
|
||||
#endif
|
||||
1
ProjetInitial/reel.ini
Executable file
1
ProjetInitial/reel.ini
Executable file
|
|
@ -0,0 +1 @@
|
|||
OSC = 8000000
|
||||
1
ProjetInitial/simu.ini
Executable file
1
ProjetInitial/simu.ini
Executable file
|
|
@ -0,0 +1 @@
|
|||
OSC = 8000000
|
||||
56
ProjetInitial/src/ADC.c
Executable file
56
ProjetInitial/src/ADC.c
Executable file
|
|
@ -0,0 +1,56 @@
|
|||
#include <stm32f10x.h>
|
||||
#include <ADC.h>
|
||||
#include <MyUart.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
//Pont diviseur du tension, coeff. = 1/13
|
||||
//Alors 13V -> 12V*1/13 = 0.92V
|
||||
|
||||
//Tension pile donné sur GPIOA.2
|
||||
void initADC(){
|
||||
//Initialisation de ADC
|
||||
|
||||
RCC->APB2ENR |= (0x1<<10); //Initialisation du clock interne du ADC2
|
||||
RCC->APB2ENR |= (0x1<<2); //GPIOA clk enable
|
||||
ADC2->CR2 |= (0x1); // ON/OFF ADC2
|
||||
|
||||
//Init de la broche PA2 en mode analog input
|
||||
GPIOA->CRL &= ~(0x00000F00);
|
||||
|
||||
ADC2->CR2 |= (0x1<<20); //External trigger enable
|
||||
ADC2->CR2 |= (0b111<<17); //SWSTART
|
||||
ADC2->CR2 |= (0x1<<1); //Continous conversion
|
||||
ADC2->SQR3 = 2;
|
||||
|
||||
//Essai de faire un nouveau Threshold/Seuil
|
||||
ADC2->CR1 |= (0x1<<23); //Watchdog enable pour mettre un threshold HIGH
|
||||
ADC2->HTR &= ~(0x0FFF);
|
||||
|
||||
//########################MAHOUT AIDEZ NOUS############################æ
|
||||
//ADC2->HTR |= 0x0475; //Changement du threshold (0.92V/3.3V)*4096
|
||||
//ADC2->HTR |= 0x0BBB; //Faut demander le prof pour ce HIGH THRESHOLD
|
||||
ADC2->CR2 |= (0x1); //ON ADC2
|
||||
}
|
||||
|
||||
int recupADC(){
|
||||
int data;
|
||||
data = ADC2->DR;
|
||||
return data;
|
||||
}
|
||||
|
||||
void sendinfoADC(){
|
||||
int valu = recupADC();
|
||||
char meld[60];
|
||||
char meld2[50];
|
||||
|
||||
int test = valu*3.3/4096;
|
||||
test = test*13*100/12;
|
||||
int tension = (13*valu)/ADC2->HTR;
|
||||
int p2 = (13*valu)/0x0FFF;
|
||||
snprintf(meld, sizeof(meld),"Pourcentage de la pile : riktig: %d next %d next %d \r\n", tension, test, p2);
|
||||
snprintf(meld2, sizeof(meld2),"Tension de la pile : %dV\r\n", tension);
|
||||
|
||||
USART_Send_String(USART1, meld2);
|
||||
}
|
||||
|
||||
187
ProjetInitial/src/Accelerometre.c
Executable file
187
ProjetInitial/src/Accelerometre.c
Executable file
|
|
@ -0,0 +1,187 @@
|
|||
#include <stm32f10x.h>
|
||||
#include <Horloge.h>
|
||||
#include <MYGPIO.h>
|
||||
#include <stdlib.h>
|
||||
#include <MySPI.h>
|
||||
#include <stdint.h>
|
||||
#include <Accelerometre.h>
|
||||
#include <stdio.h>
|
||||
#include <Timer.h>
|
||||
#include <Servo.h>
|
||||
|
||||
//Pin GPIOA_9 et GPIOA_10 sont pris par USART
|
||||
|
||||
/*
|
||||
I2C SDA IN/OUT
|
||||
I2C SCL OUT
|
||||
*/
|
||||
|
||||
//il faut recuperer le data qui sort
|
||||
|
||||
/*
|
||||
SPI1_NSS PA4 - Utilisé
|
||||
NSS = 0 -> slave active
|
||||
NSS = 1 -> slave inactive
|
||||
|
||||
SPI1_SCK PA5
|
||||
SPI1_MISO PA6
|
||||
SPI1_MOSI PA7
|
||||
|
||||
TIM3 CH3 PB0
|
||||
|
||||
0x32 50 DATAX0 R 00000000 X-Axis Data 0
|
||||
0x33 51 DATAX1 R 00000000 X-Axis Data 1
|
||||
0x34 52 DATAY0 R 00000000 Y-Axis Data 0
|
||||
0x35 53 DATAY1 R 00000000 Y-Axis Data 1
|
||||
0x36 54 DATAZ0 R 00000000 Z-Axis Data 0
|
||||
0x37 55 DATAZ1 R 00000000 Z-Axis Data 1
|
||||
|
||||
*/
|
||||
|
||||
|
||||
void initAccelo(void)
|
||||
{
|
||||
MySPI_Init(SPI1);
|
||||
|
||||
// Power_CTL register = 0x2D ? write 0x08 (MEASURE = 1)
|
||||
MySPI_Clear_NSS();
|
||||
MySPI_Send(0x31);
|
||||
MySPI_Send(0b00001101); //Justify met MSB à gauche et b0 et b1 donne resolution en +-2g
|
||||
MySPI_Set_NSS();
|
||||
|
||||
MySPI_Clear_NSS();
|
||||
MySPI_Send(0x2D & 0x3F); // write address (no read bit!)
|
||||
MySPI_Send(0x08); // set MEASURE bit
|
||||
MySPI_Set_NSS();
|
||||
|
||||
for (volatile int i = 0; i < 10000; i++); // small delay
|
||||
}
|
||||
|
||||
// send bits, les bits inclus en char envoyés: RW MB A5 A4 A3 A2 A1 A0
|
||||
//RW: R = 1 et W = 0
|
||||
//MB à 1 veut measurement et MB à 0 Standby
|
||||
uint16_t * RecupAccelo(void){ //Renvoie 48 bits en forme des chars
|
||||
static uint16_t Messias[3];
|
||||
|
||||
//On lit X0
|
||||
MySPI_Clear_NSS();//Mettre la broche PA4 à 0
|
||||
MySPI_Send(0x80|0x00|0x32); //Lecture de X0 et MB à 1 pour garder les valeurs 0b11110010: (R/W|MB|Adress)
|
||||
//Faktisk dritsmart det katten gjør, setter MB=1 som sier multiple byte read, så leser den alle 6 bytes samtidig istedenfor en og en
|
||||
uint16_t X0 = MySPI_Read();
|
||||
MySPI_Set_NSS(); //Mettre la broche PA4 à 1
|
||||
|
||||
//On lit X1
|
||||
MySPI_Clear_NSS();//Mettre la broche PA4 à 0
|
||||
MySPI_Send(0x80|0x00|0x33); //Lecture de X1
|
||||
Messias[0] = X0 | (MySPI_Read() << 8);
|
||||
MySPI_Set_NSS(); //Mettre la broche PA4 à 1
|
||||
|
||||
//On lit Y0
|
||||
MySPI_Clear_NSS();//Mettre la broche PA4 à 0
|
||||
MySPI_Send(0x80|0x00|0x34); //Lecture de Y0
|
||||
uint16_t Y0 = MySPI_Read();
|
||||
MySPI_Set_NSS(); //Mettre la broche PA4 à 1
|
||||
|
||||
//On lit Y1
|
||||
MySPI_Clear_NSS();//Mettre la broche PA4 à 0
|
||||
MySPI_Send(0x80|0x00|0x35); //Lecture de Y1
|
||||
Messias[1] = Y0 | (MySPI_Read() << 8);
|
||||
MySPI_Set_NSS(); //Mettre la broche PA4 à 1
|
||||
|
||||
//On lit Z0
|
||||
MySPI_Clear_NSS();//Mettre la broche PA4 à 0
|
||||
MySPI_Send(0x80|0x00|0x36); //Lecture de Z0
|
||||
uint16_t Z0 = MySPI_Read();
|
||||
MySPI_Set_NSS(); //Mettre la broche PA4 à 1
|
||||
|
||||
//On lit Z1
|
||||
MySPI_Clear_NSS();//Mettre la broche PA4 à 0
|
||||
MySPI_Send(0x80|0x00|0x37); //Lecture de Z1
|
||||
Messias[2] = Z0 | (MySPI_Read() << 8);
|
||||
MySPI_Set_NSS(); //Mettre la broche PA4 à 1
|
||||
|
||||
return Messias;
|
||||
}
|
||||
|
||||
|
||||
uint16_t * KattRecupAccelo(void) //Beaucoup plus smart
|
||||
{
|
||||
static uint16_t Messias[3];
|
||||
uint8_t buf[6];
|
||||
// Multi-byte read from 0x32 (X0..Z1)
|
||||
MySPI_Clear_NSS();
|
||||
// Send READ + MB + address
|
||||
MySPI_Send(0x80 | 0x40 | 0x32); // 0xF2
|
||||
// Read 6 sequential registers
|
||||
for (int i = 0; i < 6; i++) {
|
||||
buf[i] = (uint8_t)MySPI_Read();
|
||||
}
|
||||
MySPI_Set_NSS();
|
||||
// Convert little-endian to 16-bit signed values
|
||||
Messias[0] = (uint16_t)(buf[1] << 8 | buf[0]); // X
|
||||
Messias[1] = (uint16_t)(buf[3] << 8 | buf[2]); // Y
|
||||
Messias[2] = (uint16_t)(buf[5] << 8 | buf[4]); // Z
|
||||
|
||||
return Messias;
|
||||
}
|
||||
|
||||
void initLacheur(void){
|
||||
GPIOB->CRH &= ~(0xF << (0 * 4));
|
||||
GPIOB->CRH |= (0xA << (0 * 4)); //On met GPIOB.8 en mode output 2Mhz, alternate pp
|
||||
#if OSKAR
|
||||
EnableTimer(TIM4);
|
||||
MyTimer_Base_Init(TIM4, 0xFFFF, 22);
|
||||
#else
|
||||
Timer_Init(TIM4, 20000 - 1, 71); //Claire m'a aidé
|
||||
#endif
|
||||
}
|
||||
|
||||
//Recuperer le DATA en X, Z, Y
|
||||
#if MODEAVANCEE
|
||||
//volatile uint16_t Angle_lim = 0x1E20 - 60*ANGLE; //#define ANGLE_LIMITE 0x0E38
|
||||
#else
|
||||
volatile uint16_t Anngle_lim = 0x1500;
|
||||
#endif
|
||||
/*
|
||||
void LacheVoile(uint16_t voile_moy){
|
||||
if (voile_moy<=Anngle_lim){// exatement à 40 degrés, on lache le 40%. 0xFF*(40deg/90deg)
|
||||
//Le PWM du moteur est gère par PB7
|
||||
MyTimer_PWM(TIM4, 3); //TIM4 CH3 pour PB8
|
||||
Set_DutyCycle_PWM(TIM4, 3, 5); //On met Duty cycle à 2% et il reste autour de 90 deg
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
void LacheVoileNew(){
|
||||
// exatement à 40 degrés, on lache le 40%. 0xFF*(40deg/90deg)
|
||||
//Le PWM du moteur est gère par PB7
|
||||
|
||||
Servo_Moteur(0, TIM4, 3);
|
||||
}
|
||||
|
||||
void LacheVoileSmart(int AngelLim, uint16_t moyennen){
|
||||
volatile uint16_t Val_lim = 0x1E20 - 60*AngelLim;
|
||||
// exatement à 40 degrés, on lache le 40%. 0xFF*(40deg/90deg)
|
||||
//Le PWM du moteur est gère par PB7
|
||||
if (moyennen<Val_lim){
|
||||
Servo_Moteur(0, TIM4, 3);
|
||||
}
|
||||
}
|
||||
|
||||
//Gestion de l'interruption
|
||||
/*
|
||||
|
||||
void MyTimer_ActiveIT(TIM_TypeDef * Timer, char Prio, void(*Interrupt_fonc)(void)){ //On veut créer une fonction qui envoie un signal au cas où il y a debordement, avec une prioritaire, 0 plus importante 15 moins importante
|
||||
if (Timer == TIM2){
|
||||
|
||||
TIM2_Appel = Interrupt_fonc;
|
||||
|
||||
NVIC_EnableIRQ(TIM2_IRQn);
|
||||
NVIC_SetPriority(TIM2_IRQn, Prio);
|
||||
TIM2->DIER |= TIM_DIER_UIE; //Le registre DIER(Interrupt Enable Register) est mis au bit Update Interrupt, qui se commute lors d'un overflow
|
||||
TIM2->CR1 |= TIM_CR1_CEN; //Clock Enable
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
74
ProjetInitial/src/DriverGPIO.c
Executable file
74
ProjetInitial/src/DriverGPIO.c
Executable file
|
|
@ -0,0 +1,74 @@
|
|||
#include "stm32f10x.h"
|
||||
#include "DriverGPIO.h"
|
||||
#define In_Floating 0x4
|
||||
#define In_PullDown 0x8
|
||||
#define In_PullUp 0x8
|
||||
#define In_Analog 0x0
|
||||
#define Out_Ppull 0x3
|
||||
#define Out_OD 0x7
|
||||
#define AltOut_Ppull 0xB
|
||||
#define AltOut_OD 0xF
|
||||
|
||||
void MyGPIO_Init(GPIO_TypeDef * GPIO, char pin, char conf ){
|
||||
int shift_pin;
|
||||
//Start clock for relevant GPIO
|
||||
if(GPIO == GPIOA){
|
||||
RCC -> APB2ENR |= RCC_APB2ENR_IOPAEN;
|
||||
}
|
||||
else if(GPIO == GPIOB){
|
||||
RCC -> APB2ENR |= RCC_APB2ENR_IOPBEN;
|
||||
}
|
||||
else if(GPIO == GPIOC){
|
||||
RCC -> APB2ENR |= RCC_APB2ENR_IOPCEN;
|
||||
}
|
||||
else if(GPIO == GPIOD){
|
||||
RCC -> APB2ENR |= RCC_APB2ENR_IOPDEN;
|
||||
}
|
||||
if(pin < 8){//CRL zone
|
||||
shift_pin = pin*4;
|
||||
GPIO -> CRL &= ~(0xF << shift_pin);
|
||||
//PullUp and PullDown have the same conf number, so we need to change the ODR to diferenciate them both
|
||||
if(conf == In_PullUp){
|
||||
GPIO -> CRL |= ( In_PullUp << shift_pin);
|
||||
GPIO -> ODR |= (1<<pin);
|
||||
}
|
||||
else if(conf == In_PullDown){
|
||||
GPIO -> CRL |= ( In_PullDown << shift_pin);
|
||||
GPIO -> ODR &= ~(1<<pin);
|
||||
}
|
||||
else{
|
||||
GPIO -> CRL |= ( conf << shift_pin);
|
||||
}
|
||||
}
|
||||
else{//CRH zone
|
||||
shift_pin = (pin-8)*4;
|
||||
GPIO -> CRH &= ~(0xF << shift_pin);
|
||||
if(conf == In_PullUp){
|
||||
GPIO -> CRH |= ( In_PullUp << shift_pin);
|
||||
GPIO -> ODR |= (1<<pin);
|
||||
}
|
||||
else if(conf == In_PullDown){
|
||||
GPIO -> CRH |= ( In_PullDown << shift_pin);
|
||||
GPIO -> ODR &= ~(1<<pin);
|
||||
}
|
||||
else{
|
||||
GPIO -> CRH |= ( conf << shift_pin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int MyGPIO_Read(GPIO_TypeDef * GPIO, char GPIO_Pin){
|
||||
return(GPIO -> IDR & (1 << GPIO_Pin));
|
||||
}
|
||||
|
||||
void MyGPIO_Set(GPIO_TypeDef * GPIO, char GPIO_Pin){
|
||||
GPIO -> BSRR = (1<<GPIO_Pin);//1 on set zone
|
||||
}
|
||||
|
||||
void MyGPIO_Reset(GPIO_TypeDef * GPIO, char GPIO_Pin){
|
||||
GPIO -> BSRR = (1<<(GPIO_Pin+16));//1 on reset zone
|
||||
}
|
||||
|
||||
void MyGPIO_Toggle(GPIO_TypeDef * GPIO, char GPIO_Pin){
|
||||
GPIO -> ODR = GPIO -> ODR ^ (0x1 << GPIO_Pin);
|
||||
}
|
||||
48
ProjetInitial/src/Horloge.c
Executable file
48
ProjetInitial/src/Horloge.c
Executable file
|
|
@ -0,0 +1,48 @@
|
|||
#include <stm32f10x.h>
|
||||
#include <stdio.h>
|
||||
#include <Horloge.h>
|
||||
|
||||
|
||||
//Il faut trouver le signal
|
||||
//On est à Timer 2
|
||||
|
||||
static void (*TIM2_Appel)(void) = 0;
|
||||
|
||||
void Timer_Init(TIM_TypeDef *Timer, unsigned short Autoreload, unsigned short Prescaler){
|
||||
if (Timer == TIM1) {
|
||||
RCC->APB2ENR |= RCC_APB2ENR_TIM1EN; //L'horloge est enabléd
|
||||
} else if (Timer == TIM2) {
|
||||
TIM2->CR1 |= TIM_CR1_CEN; //On enable l'horloge interne
|
||||
RCC->APB1ENR |= RCC_APB1ENR_TIM2EN;
|
||||
} else if (Timer == TIM3) {
|
||||
RCC->APB1ENR |= RCC_APB1ENR_TIM3EN;
|
||||
} else if (Timer == TIM4) {
|
||||
RCC->APB1ENR |= RCC_APB1ENR_TIM4EN;
|
||||
}
|
||||
Timer->ARR |= Autoreload;
|
||||
Timer->PSC |= Prescaler;
|
||||
}
|
||||
|
||||
//La fonction TIM2_IRQHandler s'utilise dans le processeur, on l'a juste redifint, tel qu'à chaque overflow on met un bit 1 dans GPIOA_ODR
|
||||
void TIM2_IRQHandler(void) { //On redefinit le IRQHandler qui est déjà ecrit dans le code source
|
||||
if (TIM2->SR & TIM_SR_UIF) { //On met le bit de overflow à un dès qu'on a overflow
|
||||
TIM2->SR &= ~TIM_SR_UIF; //Remise à zero
|
||||
|
||||
if (TIM2_Appel){TIM2_Appel();}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MyTimer_ActiveIT(TIM_TypeDef * Timer, char Prio, void(*Interrupt_fonc)(void)){ //On veut créer une fonction qui envoie un signal au cas où il y a debordement, avec une prioritaire, 0 plus importante 15 moins importante
|
||||
if (Timer == TIM2){
|
||||
|
||||
TIM2_Appel = Interrupt_fonc;
|
||||
|
||||
NVIC_EnableIRQ(TIM2_IRQn);
|
||||
NVIC_SetPriority(TIM2_IRQn, Prio);
|
||||
TIM2->DIER |= TIM_DIER_UIE; //Le registre DIER(Interrupt Enable Register) est mis au bit Update Interrupt, qui se commute lors d'un overflow
|
||||
TIM2->CR1 |= TIM_CR1_CEN; //Clock Enable
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
97
ProjetInitial/src/MYGPIO.c
Executable file
97
ProjetInitial/src/MYGPIO.c
Executable file
|
|
@ -0,0 +1,97 @@
|
|||
#include <stdlib.h>
|
||||
#include <stm32f10x.h>
|
||||
#include <MYGPIO.h>
|
||||
|
||||
|
||||
//FONCTIONS POUR LE DEL INTERNE
|
||||
|
||||
void initGPIO_Interne(void){
|
||||
RCC->APB2ENR |= (0x01 << 2) | (0x01 << 3) | (0x01 << 4) ;
|
||||
|
||||
//Start
|
||||
//CRL pour les 8 premiers portes, CRH pour les 8 dernières portes
|
||||
if (LED_PIN_INTERNE < 8){
|
||||
LED_GPIO_INTERNE->CRL &= ~(0xF << (LED_PIN_INTERNE*4));
|
||||
LED_GPIO_INTERNE->CRL |= GPIO_OUTPUT_PPULL_MODE<<(LED_PIN_INTERNE*4) ; // On met tous les Pins de broche A à Analog Input sauf broche PA.5 qui correspond au LED GREEN: Output 2MHz et GP output push-pull
|
||||
}
|
||||
else{
|
||||
LED_GPIO_INTERNE->CRH &= ~(0xF <<((LED_PIN_INTERNE-8)*4));
|
||||
LED_GPIO_INTERNE->CRH |= GPIO_OUTPUT_PPULL_MODE<<((LED_PIN_INTERNE-8)*4);
|
||||
}
|
||||
|
||||
if (BUTTON_PIN_INTERNE < 8){
|
||||
BUTTON_GPIO_INTERNE->CRL &= ~(0xF << (BUTTON_PIN_INTERNE*4));
|
||||
BUTTON_GPIO_INTERNE->CRL |= GPIO_INPUT_FLOATING_MODE<<(BUTTON_PIN_INTERNE*4) ; // On met tous les Pins de broche A à ANalog Input sauf broche PA.5 qui correspond au LED GREEN: Output 2MHz et GP output push-pull
|
||||
}
|
||||
else{
|
||||
BUTTON_GPIO_INTERNE->CRH &= ~(0xF <<((BUTTON_PIN_INTERNE-8)*4));
|
||||
BUTTON_GPIO_INTERNE->CRH |= GPIO_INPUT_FLOATING_MODE<<((BUTTON_PIN_INTERNE-8)*4);
|
||||
}
|
||||
}
|
||||
|
||||
int boutonAppuye_Interne(void){
|
||||
return BUTTON_GPIO_INTERNE->IDR &(1<<BUTTON_PIN_INTERNE);
|
||||
}
|
||||
|
||||
void allumerDEL_Interne(void){
|
||||
LED_GPIO_INTERNE->ODR |= (0x01 << LED_PIN_INTERNE) ; //On essaie de mettre en position PA5 de GPIOC_ODR un 1 comme ca allume le LED GREEN
|
||||
}
|
||||
|
||||
void eteindreDEL_Interne(void){
|
||||
LED_GPIO_INTERNE->ODR &= ~(0x01 << LED_PIN_EXTERNE) ; //On essaie de mettre en position PA5 de GPIOC_ODR un 0 comme ca eteint le LED GREEN
|
||||
//ALlumer un LED externe, PB8/D15 OUTPUT, Bouton Poussoir PB9/D14
|
||||
}
|
||||
|
||||
void commuterDEL_Interne(void){
|
||||
LED_GPIO_INTERNE->ODR ^= (0x01 << LED_PIN_INTERNE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//FONCTIONS POUR LE DEL EXTERNE
|
||||
|
||||
void initGPIO_Externe(void){
|
||||
RCC->APB2ENR |= (0x01 << 2) | (0x01 << 3) | (0x01 << 4) ;
|
||||
|
||||
//Start
|
||||
//CRL pour les 8 premiers portes, CRH pour les 8 dernières portes
|
||||
if (LED_PIN_EXTERNE < 8){
|
||||
LED_GPIO_EXTERNE->CRL &= ~(0xF << (LED_PIN_EXTERNE*4));
|
||||
LED_GPIO_EXTERNE->CRL |= GPIO_OUTPUT_PPULL_MODE<<(LED_PIN_EXTERNE*4) ; // On met tous les Pins de broche A à ANalog Input sauf broche PA.5 qui correspond au LED GREEN: Output 2MHz et GP output push-pull
|
||||
}
|
||||
else{
|
||||
LED_GPIO_EXTERNE->CRH &= ~(0xF <<((LED_PIN_EXTERNE-8)*4));
|
||||
LED_GPIO_EXTERNE->CRH |= GPIO_OUTPUT_PPULL_MODE<<((LED_PIN_EXTERNE-8)*4);
|
||||
}
|
||||
|
||||
if (BUTTON_PIN_EXTERNE < 8){
|
||||
BUTTON_GPIO_EXTERNE->CRL &= ~(0xF << (BUTTON_PIN_EXTERNE*4));
|
||||
BUTTON_GPIO_EXTERNE->CRL |= GPIO_INPUT_FLOATING_MODE<<(BUTTON_PIN_EXTERNE*4) ; // On met tous les Pins de broche A à ANalog Input sauf broche PA.5 qui correspond au LED GREEN: Output 2MHz et GP output push-pull
|
||||
}
|
||||
else{
|
||||
BUTTON_GPIO_EXTERNE->CRH &= ~(0xF <<((BUTTON_PIN_EXTERNE-8)*4));
|
||||
BUTTON_GPIO_EXTERNE->CRH |= GPIO_INPUT_FLOATING_MODE<<((BUTTON_PIN_EXTERNE-8)*4);
|
||||
}
|
||||
}
|
||||
|
||||
int boutonAppuye_Externe(void){
|
||||
return BUTTON_GPIO_EXTERNE->IDR &(1<<BUTTON_PIN_EXTERNE);
|
||||
}
|
||||
|
||||
void allumerDEL_Externe(void){
|
||||
LED_GPIO_EXTERNE->ODR |= (0x01 << LED_PIN_EXTERNE) ;
|
||||
} //On essaie de mettre en position PA5 de GPIOC_ODR un 1 comme ca allume le LED GREEN
|
||||
|
||||
|
||||
void eteindreDEL_Externe(void){
|
||||
LED_GPIO_EXTERNE->ODR &= ~(0x01 << LED_PIN_EXTERNE) ; //On essaie de mettre en position PA5 de GPIOC_ODR un 0 comme ca eteint le LED GREEN
|
||||
//ALlumer un LED externe, PB8/D15 OUTPUT, Bouton Poussoir PB9/D14
|
||||
}
|
||||
|
||||
void commuterDEL_Externe(void){
|
||||
LED_GPIO_EXTERNE->ODR ^= (0x01 << LED_PIN_EXTERNE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
54
ProjetInitial/src/MyTimer.c
Executable file
54
ProjetInitial/src/MyTimer.c
Executable file
|
|
@ -0,0 +1,54 @@
|
|||
#include <stm32f10x.h>
|
||||
#include <Timer.h>
|
||||
#include <MyTimer.h>
|
||||
#include <PWM.h>
|
||||
#include <DriverGPIO.h>
|
||||
#include <Horloge.h>
|
||||
|
||||
// Constantes
|
||||
#define ARR_TIM1 0xFFAD
|
||||
#define PSC_TIM1 0xFF
|
||||
#define ARR_TIM2 0xFFAD
|
||||
#define PSC_TIM2 0x0225
|
||||
#define ARR_TIM3 0x2CF
|
||||
#define PSC_TIM3 0x0
|
||||
|
||||
// Variables
|
||||
volatile int g_tick_count;
|
||||
|
||||
|
||||
void Test(void) {
|
||||
// Signal
|
||||
g_tick_count++;
|
||||
MyGPIO_Toggle(GPIOA, 8);
|
||||
}
|
||||
|
||||
// LES COMMENTAIRES SONT POUR ACTIVER DES TIMERS QUE L'ON UTILISE PAS POUR LE MOMENT
|
||||
void ConfigureTimers() {
|
||||
// Config ARR & PSC
|
||||
//MyTimer_Base_Init(TIM2, ARR_TIM2, PSC_TIM2);
|
||||
//MyTimer_Base_Init(TIM1, ARR_TIM1, PSC_TIM1);
|
||||
//MyTimer_Base_Init(TIM3, ARR_TIM2, PSC_TIM2);
|
||||
//Timer_Init(TIM1, ARR_TIM1, PSC_TIM1);
|
||||
Timer_Init(TIM2, 0, 0);
|
||||
Timer_Init(TIM8, 0, 0);
|
||||
|
||||
// Enable timer clock
|
||||
//EnableTimer(TIM1);
|
||||
//EnableTimer(TIM2);
|
||||
//EnableTimer(TIM3);
|
||||
}
|
||||
|
||||
|
||||
void ConfigureIT() { // Activate general interuption with a function and priority
|
||||
//MyTimer_ActiveIT(TIM2, 4, Test); //start interruption with priority 4
|
||||
//MyTimer_ActiveIT(TIM1, 4, Test); //start interruption with priority 4
|
||||
MyTimer_ActiveIT(TIM3, 4, Test); //start interruption with priority 4
|
||||
}
|
||||
|
||||
|
||||
void ConfigurePWM() { // Set dutycycle with timer
|
||||
MyTimer_PWM(TIM8, 2); // Utiliser timer1 avec channel 1
|
||||
//MyTimer_Set_DutyCycle(TIM1, 1, 20.0);
|
||||
}
|
||||
|
||||
109
ProjetInitial/src/PWM.c
Executable file
109
ProjetInitial/src/PWM.c
Executable file
|
|
@ -0,0 +1,109 @@
|
|||
#include "stm32f10x.h"
|
||||
#include "PWM.h"
|
||||
|
||||
void MyTimer_PWM(TIM_TypeDef * Timer , int Channel){
|
||||
int pwrmd;
|
||||
#if POWERMODE //Powermode 1
|
||||
pwrmd = 0b110;
|
||||
#else
|
||||
pwrmd = 0b111; //Powermode 2
|
||||
#endif
|
||||
|
||||
if (Channel == 1){
|
||||
Timer->CCMR1 &= ~(0b111<<4); //On clear les trois bits qui sont de pwm
|
||||
Timer->CCMR1 |= (pwrmd<<4); //On affecte le powermode au bits de lecture pour le µ-controlleur
|
||||
Timer->CCMR1 |= TIM_CCMR1_OC1PE; //Update preload, il n'affecte pas le valeur avant que la prochaine cycle
|
||||
Timer->CCER = TIM_CCER_CC1E; //Enable le pin voulu basculer
|
||||
}
|
||||
else if (Channel == 2){
|
||||
Timer->CCMR1 &= ~(0b111<<12); //Le TIMx_CCMR1 configure deux channels, de bit [6:4] CH1, [14:12] CH2 (OC2M = Output Channel 2 )
|
||||
Timer->CCMR1 |= (pwrmd<<12);
|
||||
Timer->CCMR1 |= TIM_CCMR1_OC2PE;
|
||||
Timer->CCER |= TIM_CCER_CC2E;
|
||||
}
|
||||
else if (Channel == 3){
|
||||
Timer->CCMR1 &= ~(0b111<<4);
|
||||
Timer->CCMR2 |= (pwrmd<<4);
|
||||
Timer->CCMR2 |= TIM_CCMR2_OC3PE;
|
||||
Timer->CCER |= TIM_CCER_CC3E;
|
||||
}
|
||||
else if (Channel == 4){
|
||||
Timer->CCMR1 &= ~(0b111<<12);
|
||||
Timer->CCMR2 |= (pwrmd<<12);
|
||||
Timer->CCMR2 |= TIM_CCMR2_OC4PE;
|
||||
Timer->CCER |= TIM_CCER_CC4E;
|
||||
}
|
||||
|
||||
//En dessous d'ici, on a l'aide du plus gentil chat que je connais
|
||||
// Enable auto-reload preload -- //Ensures that your initial configuration — PWM mode, duty cycle, period — actually takes effect before the timer starts counting.
|
||||
Timer->CR1 |= TIM_CR1_ARPE;
|
||||
// Force update event to load ARR and CCR values immediately
|
||||
Timer->EGR |= TIM_EGR_UG;
|
||||
// Start the timer
|
||||
Timer->CR1 |= TIM_CR1_CEN;
|
||||
|
||||
switch (Channel) {
|
||||
case 1:
|
||||
if (Timer == TIM1){GPIOA->CRH &= ~(0xF<<0*4); GPIOA->CRH |= (0xA<<0*4); TIM1->BDTR |= 1<<15; }
|
||||
if (Timer == TIM2){GPIOA->CRL &= ~(0xF<<0*4); GPIOA->CRL |= (0xA<<0*4);}
|
||||
if (Timer == TIM3){GPIOA->CRL &= ~(0xF<<6*4); GPIOA->CRL |= (0xA<<6*4);}
|
||||
if (Timer == TIM4){GPIOB->CRL &= ~(0xF<<5*4); GPIOB->CRL |= (0xA<<5*4);}
|
||||
break;
|
||||
case 2:
|
||||
if (Timer == TIM1){GPIOA->CRH &= ~(0xF<<1*4); GPIOA->CRL |= (0xA<<1*4); TIM1->BDTR |= 1<<15;}
|
||||
if (Timer == TIM2){GPIOA->CRL &= ~(0xF<<1*4); GPIOA->CRL |= (0xA<<1*4);}
|
||||
if (Timer == TIM3){GPIOA->CRL &= ~(0xF<<7*4); GPIOA->CRL |= (0xA<<7*4);}
|
||||
if (Timer == TIM4){GPIOB->CRL &= ~(0xF<<7*4); GPIOB->CRL |= (0xA<<7*4);}
|
||||
break;
|
||||
case 3:
|
||||
if (Timer == TIM1){GPIOA->CRH &= ~(0xF<<2*4); GPIOA->CRH |= (0xA<<2*4); TIM1->BDTR |= 1<<15;}
|
||||
if (Timer == TIM2){GPIOA->CRL &= ~(0xF<<2*4); GPIOA->CRL |= (0xA<<2*4);}
|
||||
if (Timer == TIM3){GPIOB->CRL &= ~(0xF<<0*4); GPIOB->CRL |= (0xA<<0*4);}
|
||||
if (Timer == TIM4){GPIOB->CRH &= ~(0xF<<0*4); GPIOB->CRH |= (0xA<<0*4);}
|
||||
break;
|
||||
case 4:
|
||||
if (Timer == TIM1){GPIOA->CRH &= ~(0xF<<3*4); GPIOA->CRH |= (0xA<<3*4); TIM1->BDTR |= 1<<15;}
|
||||
if (Timer == TIM2){GPIOA->CRL &= ~(0xF<<3*4); GPIOA->CRL |= (0xA<<3*4);}
|
||||
if (Timer == TIM3){GPIOB->CRL &= ~(0xF<<1*4); GPIOB->CRL |= (0xA<<1*4);}
|
||||
if (Timer == TIM4){GPIOB->CRH &= ~(0xF<<1*4); GPIOB->CRH |= (0xA<<1*4);}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//Une fonction qui met le bon PWM voulu
|
||||
int Set_DutyCycle_PWM(TIM_TypeDef *Timer, int Channel, int DutyC){
|
||||
int CCR_VAL = (Timer -> ARR + 1) * DutyC / 100;
|
||||
switch (Channel){
|
||||
case 1: Timer->CCR1 = CCR_VAL;
|
||||
case 2: Timer->CCR2 = CCR_VAL;
|
||||
case 3: Timer->CCR3 = CCR_VAL;
|
||||
case 4: Timer->CCR4 = CCR_VAL;
|
||||
default: break;
|
||||
}
|
||||
return 0;
|
||||
Timer->EGR |= TIM_EGR_UG;
|
||||
}
|
||||
|
||||
// NOuvelle Set_D
|
||||
int Set_DutyCycle_PWM_Plateau(TIM_TypeDef *Timer, int Channel, int DutyC){
|
||||
int CCR_VAL = (Timer->ARR + 1) * DutyC / 100;
|
||||
switch (Channel){
|
||||
case 1:
|
||||
Timer->CCR1 = CCR_VAL;
|
||||
break;
|
||||
case 2:
|
||||
Timer->CCR2 = CCR_VAL;
|
||||
break;
|
||||
case 3:
|
||||
|
||||
Timer->CCR3 = CCR_VAL;
|
||||
break;
|
||||
case 4:
|
||||
Timer->CCR4 = CCR_VAL;
|
||||
break;
|
||||
default:
|
||||
return -1; // channel invalide
|
||||
}
|
||||
Timer->EGR |= TIM_EGR_UG; // update event
|
||||
return 0;
|
||||
}
|
||||
29
ProjetInitial/src/Servo.c
Executable file
29
ProjetInitial/src/Servo.c
Executable file
|
|
@ -0,0 +1,29 @@
|
|||
#include <Servo.h>
|
||||
#include <DriverGPIO.h>
|
||||
#include <PWM.h>
|
||||
#include <Timer.h>
|
||||
|
||||
void Servo_Moteur(int angle, TIM_TypeDef * Timer, int Channel){ // Controle du moteur
|
||||
int dutyCycle = (5* angle + 5*90)/90; // 5-10 % Duty Cycle
|
||||
Set_DutyCycle_PWM(Timer, Channel, dutyCycle);
|
||||
}
|
||||
|
||||
void initServo(TIM_TypeDef * Timer, int Channel){ // Config du moteur servo
|
||||
if (Timer == TIM4) {
|
||||
EnableTimer(TIM4);
|
||||
//MyTimer_Base_Init(TIM4, 20000 - 1, 71);
|
||||
MyTimer_Base_Init(TIM4, 0xFFFF, 22); // Pour obtenir un période de 20 ms
|
||||
|
||||
if (Channel == 3){
|
||||
MyGPIO_Init(GPIOB, 8, AltOut_Ppull); // Outut push pull alternate
|
||||
MyTimer_PWM(TIM4, 3); //TIM4 CH3 pour PB8
|
||||
}
|
||||
else{
|
||||
//printf("Cet pilôte n'existe pas");
|
||||
}
|
||||
}
|
||||
else{
|
||||
//printf("Cet pilôte n'existe pas");
|
||||
}
|
||||
}
|
||||
|
||||
27
ProjetInitial/src/Timer.c
Executable file
27
ProjetInitial/src/Timer.c
Executable file
|
|
@ -0,0 +1,27 @@
|
|||
#include <stm32f10x.h>
|
||||
#include <Timer.h>
|
||||
|
||||
void MyTimer_Base_Init( TIM_TypeDef * Timer , unsigned short ValARR , unsigned short ValPSC ) { // Configuration du timer
|
||||
Timer -> PSC=(ValPSC);
|
||||
Timer-> ARR = (ValARR);
|
||||
Timer->EGR |= TIM_EGR_UG;
|
||||
};
|
||||
|
||||
|
||||
|
||||
void EnableTimer(TIM_TypeDef *Timer){
|
||||
if(Timer == TIM2){
|
||||
RCC -> APB1ENR |= RCC_APB1ENR_TIM2EN;
|
||||
}
|
||||
else if(Timer == TIM3){
|
||||
RCC -> APB1ENR |= RCC_APB1ENR_TIM3EN;
|
||||
}
|
||||
else if(Timer == TIM4){
|
||||
RCC -> APB1ENR |= RCC_APB1ENR_TIM4EN;
|
||||
}
|
||||
else if(Timer == TIM1){
|
||||
RCC->APB2ENR |= RCC_APB2ENR_TIM1EN;
|
||||
}
|
||||
else{
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue