From bc481107298791bf0efd984ecc53dc92b8719878 Mon Sep 17 00:00:00 2001 From: Clyhtsuriva Date: Tue, 26 Jan 2021 18:26:26 +0100 Subject: Insertion du projet dans sa totalité MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Core/Src/button.c | 33 ---- Core/Src/gpio.c | 87 --------- Core/Src/lcd_1602.c | 78 --------- Core/Src/led.c | 44 ----- Core/Src/main.c | 409 ------------------------------------------- Core/Src/stm32l0xx_hal_msp.c | 84 --------- Core/Src/stm32l0xx_it.c | 147 ---------------- Core/Src/syscalls.c | 207 ---------------------- Core/Src/system_stm32l0xx.c | 275 ----------------------------- Core/Src/usart.c | 108 ------------ 10 files changed, 1472 deletions(-) delete mode 100644 Core/Src/button.c delete mode 100644 Core/Src/gpio.c delete mode 100644 Core/Src/lcd_1602.c delete mode 100644 Core/Src/led.c delete mode 100644 Core/Src/main.c delete mode 100644 Core/Src/stm32l0xx_hal_msp.c delete mode 100644 Core/Src/stm32l0xx_it.c delete mode 100644 Core/Src/syscalls.c delete mode 100644 Core/Src/system_stm32l0xx.c delete mode 100644 Core/Src/usart.c (limited to 'Core/Src') diff --git a/Core/Src/button.c b/Core/Src/button.c deleted file mode 100644 index a9333d9..0000000 --- a/Core/Src/button.c +++ /dev/null @@ -1,33 +0,0 @@ -/* - * button.c - * - * Created on: 2 déc. 2020 - * Author: root - */ - -#include "button.h" - -void Button_init(BUTTON_TypeDef *button, GPIO_TypeDef * port, uint8_t pn,uint8_t pl) { -button->gpioPort = port; -button->pin = pn; -button->pull = pl; - -//Activation de l'horloge sur le port en question - -//déterminer le numéro du port 0--> GPIOA, 1-->GPIOB, etc. -uint8_t nb_port; -nb_port = ((uint32_t) port - IOPPERIPH_BASE) / 0x400; -//activation de l'hologe -RCC->IOPENR |= 1 << nb_port; -//configuration de la pin en entrée -button->gpioPort->MODER &= ~(0b11 << 2 * pn); -//configuration du type de pull -button->gpioPort->PUPDR &= ~(0b11 << 2 * pn); -button->gpioPort->PUPDR |= (pl << 2 * pn); -} - -uint8_t Button_State(BUTTON_TypeDef *button) { -if ((button->gpioPort->IDR & (1 << button->pin)) != 0) -return 1; -return 0; -} diff --git a/Core/Src/gpio.c b/Core/Src/gpio.c deleted file mode 100644 index b80c7b9..0000000 --- a/Core/Src/gpio.c +++ /dev/null @@ -1,87 +0,0 @@ -/** - ****************************************************************************** - * @file gpio.c - * @brief This file provides code for the configuration - * of all used GPIO pins. - ****************************************************************************** - * @attention - * - *

© Copyright (c) 2021 STMicroelectronics. - * All rights reserved.

- * - * This software component is licensed by ST under BSD 3-Clause license, - * the "License"; You may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * opensource.org/licenses/BSD-3-Clause - * - ****************************************************************************** - */ - -/* Includes ------------------------------------------------------------------*/ -#include "gpio.h" - -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ - -/*----------------------------------------------------------------------------*/ -/* Configure GPIO */ -/*----------------------------------------------------------------------------*/ -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ - -/** Configure pins as - * Analog - * Input - * Output - * EVENT_OUT - * EXTI -*/ -void MX_GPIO_Init(void) -{ - - GPIO_InitTypeDef GPIO_InitStruct = {0}; - - /* GPIO Ports Clock Enable */ - __HAL_RCC_GPIOC_CLK_ENABLE(); - __HAL_RCC_GPIOH_CLK_ENABLE(); - __HAL_RCC_GPIOA_CLK_ENABLE(); - __HAL_RCC_GPIOB_CLK_ENABLE(); - - /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, GPIO_PIN_RESET); - - /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(GPIOB, RS_Pin|RW_Pin|E_Pin|D4_Pin - |D5_Pin|D6_Pin|D7_Pin, GPIO_PIN_RESET); - - /*Configure GPIO pin : PtPin */ - GPIO_InitStruct.Pin = B1_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(B1_GPIO_Port, &GPIO_InitStruct); - - /*Configure GPIO pin : PtPin */ - GPIO_InitStruct.Pin = LD2_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; - HAL_GPIO_Init(LD2_GPIO_Port, &GPIO_InitStruct); - - /*Configure GPIO pins : PBPin PBPin PBPin PBPin - PBPin PBPin PBPin */ - GPIO_InitStruct.Pin = RS_Pin|RW_Pin|E_Pin|D4_Pin - |D5_Pin|D6_Pin|D7_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; - HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); - -} - -/* USER CODE BEGIN 2 */ - -/* USER CODE END 2 */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/Core/Src/lcd_1602.c b/Core/Src/lcd_1602.c deleted file mode 100644 index 4dc09b9..0000000 --- a/Core/Src/lcd_1602.c +++ /dev/null @@ -1,78 +0,0 @@ -#include "lcd_1602.h" - -static void delay_us(uint32_t delay){ - delay*=32; - while(delay--); -} - -static void lcd_send_4bit(uint8_t data) { - - if(data & 0x10) d4(1); else d4(0); - if(data & 0x20) d5(1); else d5(0); - if(data & 0x40) d6(1); else d6(0); - if(data & 0x80) d7(1); else d7(0); - -} - -static void lcd_send(int8_t rs,uint8_t data){ - // rs : 1=data | 2=command - // rw : 0=write | 1=read - // en : 1=senddata | 0=donothing - - rs(rs); - rw(0); - lcd_send_4bit(data); //MSB - en(1); - delay_us(100); - en(0); - lcd_send_4bit(data<<4); //LSB - en(1); - delay_us(100); - en(0); -} - -void lcd_cmd(uint8_t command){ - lcd_send(1,command); -} - -void lcd_data(char c){ - lcd_send(1,(uint8_t)c); - -} - -void lcd_init(void){ - //bl(1); - -// lcd_send(0x22); - - // 4 bit initialisation - lcd_send(0,0x20); // 4bit mode - HAL_Delay(10); - - // Display initialisation - lcd_send(0,0x28); // Function set --> DL=0 (4 bit mode), N = 1 (2 line display) F = 0 (5x8 characters) - HAL_Delay(1); - lcd_send(0,0x08); //Display on/off control --> D=0,C=0, B=0 ---> display off - HAL_Delay(1); - lcd_send(0,0x01); // clear display - HAL_Delay(2); - lcd_send(0,0x06); //Entry mode set --> I/D = 1 (increment cursor) & S = 0 (no shift) - HAL_Delay(1); - lcd_send(0,0x0C); //Display on/off control --> D = 1, C and B = 0. (Cursor and blink, last two bits) - HAL_Delay(2); -} - -void lcd_clr(void){ - lcd_send(0,0x01); - HAL_Delay(2); -} - - -void lcd_gotoxy(char x, char y){ - lcd_send(0,0x80+x+(y*0x40)); - HAL_Delay(2); -} - -void lcd_puts(char *text){ - while (*text) lcd_data (*text++); -} diff --git a/Core/Src/led.c b/Core/Src/led.c deleted file mode 100644 index 1a5c58f..0000000 --- a/Core/Src/led.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * led.c - * - * Created on: 2 déc. 2020 - * Author: root - */ - -#include "led.h" - -void Led_init(LED_TypeDef *led, GPIO_TypeDef * port, uint16_t pn){ -led->gpioPort=port; -led->pin=pn; - -//Activation de l'horloge sur le port en question - -//déterminer le numéro du port 0--> GPIOA, 1-->GPIOB, etc. -uint8_t nb_port; -nb_port=(uint32_t)((uint32_t *)port - IOPPERIPH_BASE)/ (uint32_t)0x400; -//activation de l'hologe -RCC->IOPENR|=1<gpioPort->MODER&=~(0b11<<2*pn); -led->gpioPort->MODER|=(0b01<<2*pn); -} - -uint8_t Led_isOn(LED_TypeDef *led){ -return ((led->gpioPort->ODR&(1<pin))!=0); -} - -uint8_t Led_isOff(LED_TypeDef *led){ -return ((led->gpioPort->ODR&(1<pin))==0); -} -void Led_turnOn(LED_TypeDef *led){ -led->gpioPort->ODR|=(1<pin); -} - -void Led_turnOff(LED_TypeDef *led){ -led->gpioPort->ODR&=~(1<pin); -} - -void Led_toggle(LED_TypeDef *led){ - led->gpioPort->ODR^=(1<pin); -} diff --git a/Core/Src/main.c b/Core/Src/main.c deleted file mode 100644 index 1001ae9..0000000 --- a/Core/Src/main.c +++ /dev/null @@ -1,409 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file : main.c - * @brief : Main program body - ****************************************************************************** - * @attention - * - *

© Copyright (c) 2020 STMicroelectronics. - * All rights reserved.

- * - * This software component is licensed by ST under BSD 3-Clause license, - * the "License"; You may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * opensource.org/licenses/BSD-3-Clause - * - ****************************************************************************** - */ -/* USER CODE END Header */ -/* Includes ------------------------------------------------------------------*/ -#include "main.h" -#include "usart.h" -#include "gpio.h" - -/* Private includes ----------------------------------------------------------*/ -/* USER CODE BEGIN Includes */ -#include "led.h" -#include "button.h" -#include "lcd_1602.h" -#include -#include -#include -#include -#include -/* USER CODE END Includes */ -/* Private typedef -----------------------------------------------------------*/ -/* USER CODE BEGIN PTD */ - -/* USER CODE END PTD */ - -/* Private define ------------------------------------------------------------*/ -/* USER CODE BEGIN PD */ -/* USER CODE END PD */ - -/* Private macro -------------------------------------------------------------*/ -/* USER CODE BEGIN PM */ - -/* USER CODE END PM */ - -/* Private variables ---------------------------------------------------------*/ - -/* USER CODE BEGIN PV */ - -/* USER CODE END PV */ - -/* Private function prototypes -----------------------------------------------*/ -void SystemClock_Config(void); -/* USER CODE BEGIN PFP */ - -/* USER CODE END PFP */ - -/* Private user code ---------------------------------------------------------*/ - -/* USER CODE BEGIN 0 */ -//Declaration des leds et buttons -LED_TypeDef led_rouge; //rouge -LED_TypeDef led_verte; //verte -LED_TypeDef led_jaune; //jaune -LED_TypeDef led_system; //vert sur la carte - -BUTTON_TypeDef button_rouge; //rouge -BUTTON_TypeDef button_vert; //vert -BUTTON_TypeDef button_jaune; //jaune -BUTTON_TypeDef button_deux_joueur; //gris -BUTTON_TypeDef button_system; //bleu sur la carte - -// fonction pour allumer et eteindre les leds -void fonction_led(char* couleur, int position) { - if (strcmp(couleur,"R")==0 && (position==0)){ //eteind rouge - Led_turnOff(&led_rouge); - } else if (strcmp(couleur,"R")==0 && (position==1)){ //allume rouge - Led_turnOn(&led_rouge); - } else if (strcmp(couleur,"V")==0 && (position==0)){ - Led_turnOff(&led_verte); - } else if (strcmp(couleur,"V")==0 && (position==1)){ - Led_turnOn(&led_verte); - } else if (strcmp(couleur,"J")==0 && (position==0)){ - Led_turnOff(&led_jaune); - } else if (strcmp(couleur,"J")==0 && (position==1)){ - Led_turnOn(&led_jaune); - } else if (strcmp(couleur,"S")==0 && (position==0)){ - Led_turnOff(&led_system); - } else if (strcmp(couleur,"S")==0 && (position==1)){ - Led_turnOn(&led_system); - } -} - -void affiche_lcd(char* contenu, int positiony, int clear) { - if (clear==1){ - lcd_clr(); - } - lcd_gotoxy(0,positiony); - lcd_puts(contenu); -} - -char* choix_aleatoire(void) { - char* couleur_leds[3]={"R","V","J"}; //nos couleurs de led - srand(time(0)); - int aleatoire = (rand() % (2 - 0 + 1)) + 0; //choix entre 0 et 2 pour avoir 3 valeurs differentes (3 couleurs/leds) - char* choix = couleur_leds[aleatoire]; - return choix; -} - -/* USER CODE END 0 */ - -/** - * @brief The application entry point. - * @retval int - */ -int main(void) -{ - /* USER CODE BEGIN 1 */ - - /* USER CODE END 1 */ - - /* MCU Configuration--------------------------------------------------------*/ - - /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ - HAL_Init(); - - /* USER CODE BEGIN Init */ - - /* USER CODE END Init */ - - /* Configure the system clock */ - SystemClock_Config(); - - /* USER CODE BEGIN SysInit */ - - /* USER CODE END SysInit */ - - /* Initialize all configured peripherals */ - MX_GPIO_Init(); - MX_USART2_UART_Init(); - /* USER CODE BEGIN 2 */ - -// - //configuration de l'horloge du système en 16MHz - RCC->CR|=1; //activer HSI - RCC->CFGR&=~(0b11); - RCC->CFGR|=01; //selection de HSI - HAL_InitTick(16000000); -// - -// Init de nos leds et buttons - Led_init(&led_system, GPIOA,5); //led_system sur PA5 - Led_init(&led_rouge, GPIOA,6); //led_rouge sur PA6 - Led_init(&led_verte, GPIOA,7); //led_verte sur PA7 - Led_init(&led_jaune, GPIOB,6); //led_jaune sur PB6 - - Button_init(&button_system, GPIOC, 13); //button_system sur PC13 - Button_init(&button_rouge, GPIOC, 14); //button_rouge sur PC13 - Button_init(&button_vert, GPIOC, 15); //button_vert sur PC13 - Button_init(&button_jaune, GPIOH, 0); //button_jaune sur PH0 - Button_init(&button_deux_joueur, GPIOH, 1); //button_deux_joueur sur PH1 -// - -/* EXEMPLE D'UTILISATION POUR LED ET BUTTON - uint8_t last_button_state = 1; //button non appuyé - uint8_t current_button_state = 1; //button non appuyé - - for (;;) { - //lire l’état courant - current_button_state = Button_State(&button_system); - //si front descendant (bouton appuyé) - if (last_button_state == 1 && (current_button_state == 0)) { - Led_turnOn(&led_system); //allume - //suppression des rebonds - HAL_Delay(20); - } - //si front montant (bouton relâché) - if (last_button_state == 0 && (current_button_state != 0)) { - //suppression des rebonds - HAL_Delay(20); - Led_turnOff(&led_system); //eteind - } - //mise à jour de l’état précédent du bouton - last_button_state = current_button_state; - } -*/ - affiche_lcd("SIMON_STM32",0,1); - - int score = 0; //pour le systeme de score - int deuxieme_joueur_joue = 0; //pour check si le 2e joueur a joué - int score_un=0; //pour store le score du j1 - int score_deux=0; //pour store le score du j1 - char* suite_de_leds[100]={}; //la suite de leds a faire cligoter - - /* USER CODE END 2 */ - - /* Infinite loop */ - - while (1) - { - /* USER CODE BEGIN WHILE */ - lcd_init(); - - -//gestion du mode 2joueurs - uint8_t last_button_2j_state = 1; - uint8_t current_button_2j_state = 1; - int etat_bouton_deux_joueurs=0; - - //lire l’état courant - current_button_2j_state = Button_State(&button_deux_joueur); - //si front descendant (bouton appuyé) - if (last_button_2j_state == 1 && (current_button_2j_state == 0) && (etat_bouton_deux_joueurs==0)) { - etat_bouton_deux_joueurs = 1; - fonction_led("S",1); //allume la led de la carte - } else if (last_button_2j_state == 1 && (current_button_2j_state == 0) && (etat_bouton_deux_joueurs==1)) { - etat_bouton_deux_joueurs = 0; - fonction_led("S",0); //eteind la led de la carte - } - //mise à jour de l’état précédent du bouton - last_button_2j_state = current_button_2j_state; - - -//gestion du bouton start/system - uint8_t last_button_system_state = 1; //button non appuyé - uint8_t current_button_system_state = 1; //button non appuyé - int etat_bouton_start=0; - - //lire l’état courant - current_button_system_state = Button_State(&button_system); - //si front descendant (bouton appuyé) - if (last_button_system_state == 1 && (current_button_system_state == 0) && (etat_bouton_deux_joueurs==0)) { - etat_bouton_start = 1; - } else if (last_button_system_state == 1 && (current_button_system_state == 0) && (etat_bouton_deux_joueurs==1)) { - etat_bouton_start = 0; - } - //mise à jour de l’état précédent du bouton - last_button_system_state = current_button_system_state; - - - int perdu = 0; //pour check si le j a perdu - - if (etat_bouton_start){ -//Sequence d'allumage - affiche_lcd("LET'S GO !",0,1); - fonction_led("R", 1); - HAL_Delay(250); - fonction_led("V", 1); - HAL_Delay(250); - fonction_led("J", 1); - HAL_Delay(250); - fonction_led("R", 0); - HAL_Delay(250); - fonction_led("V", 0); - HAL_Delay(250); - fonction_led("J", 0); - HAL_Delay(250); - - if (etat_bouton_deux_joueurs && !deuxieme_joueur_joue){ //lancement du mode 2J - affiche_lcd("MODE 2J",0,1); - affiche_lcd("J1!",1,0); - } - else if (!etat_bouton_deux_joueurs && !deuxieme_joueur_joue) { //lancement du mode 1J - affiche_lcd("MODE 1J",0,1); - } - - while (perdu!= 1) { //ici on lance un niveau (suite de leds), tant qu'on a pas perdu - - suite_de_leds[score] = choix_aleatoire(); - score++; - for (int i = 0; iscore_deux){affiche_lcd("JOUEUR 1 GAGNE!",0,1);} - else if (score_un
© Copyright (c) 2021 STMicroelectronics. - * All rights reserved.
- * - * This software component is licensed by ST under BSD 3-Clause license, - * the "License"; You may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * opensource.org/licenses/BSD-3-Clause - * - ****************************************************************************** - */ -/* USER CODE END Header */ - -/* Includes ------------------------------------------------------------------*/ -#include "main.h" -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* Private typedef -----------------------------------------------------------*/ -/* USER CODE BEGIN TD */ - -/* USER CODE END TD */ - -/* Private define ------------------------------------------------------------*/ -/* USER CODE BEGIN Define */ - -/* USER CODE END Define */ - -/* Private macro -------------------------------------------------------------*/ -/* USER CODE BEGIN Macro */ - -/* USER CODE END Macro */ - -/* Private variables ---------------------------------------------------------*/ -/* USER CODE BEGIN PV */ - -/* USER CODE END PV */ - -/* Private function prototypes -----------------------------------------------*/ -/* USER CODE BEGIN PFP */ - -/* USER CODE END PFP */ - -/* External functions --------------------------------------------------------*/ -/* USER CODE BEGIN ExternalFunctions */ - -/* USER CODE END ExternalFunctions */ - -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ -/** - * Initializes the Global MSP. - */ -void HAL_MspInit(void) -{ - /* USER CODE BEGIN MspInit 0 */ - - /* USER CODE END MspInit 0 */ - - __HAL_RCC_SYSCFG_CLK_ENABLE(); - __HAL_RCC_PWR_CLK_ENABLE(); - - /* System interrupt init*/ - - /* USER CODE BEGIN MspInit 1 */ - - /* USER CODE END MspInit 1 */ -} - -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/Core/Src/stm32l0xx_it.c b/Core/Src/stm32l0xx_it.c deleted file mode 100644 index bf098ed..0000000 --- a/Core/Src/stm32l0xx_it.c +++ /dev/null @@ -1,147 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file stm32l0xx_it.c - * @brief Interrupt Service Routines. - ****************************************************************************** - * @attention - * - *

© Copyright (c) 2021 STMicroelectronics. - * All rights reserved.

- * - * This software component is licensed by ST under BSD 3-Clause license, - * the "License"; You may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * opensource.org/licenses/BSD-3-Clause - * - ****************************************************************************** - */ -/* USER CODE END Header */ - -/* Includes ------------------------------------------------------------------*/ -#include "main.h" -#include "stm32l0xx_it.h" -/* Private includes ----------------------------------------------------------*/ -/* USER CODE BEGIN Includes */ -/* USER CODE END Includes */ - -/* Private typedef -----------------------------------------------------------*/ -/* USER CODE BEGIN TD */ - -/* USER CODE END TD */ - -/* Private define ------------------------------------------------------------*/ -/* USER CODE BEGIN PD */ - -/* USER CODE END PD */ - -/* Private macro -------------------------------------------------------------*/ -/* USER CODE BEGIN PM */ - -/* USER CODE END PM */ - -/* Private variables ---------------------------------------------------------*/ -/* USER CODE BEGIN PV */ - -/* USER CODE END PV */ - -/* Private function prototypes -----------------------------------------------*/ -/* USER CODE BEGIN PFP */ - -/* USER CODE END PFP */ - -/* Private user code ---------------------------------------------------------*/ -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ - -/* External variables --------------------------------------------------------*/ - -/* USER CODE BEGIN EV */ - -/* USER CODE END EV */ - -/******************************************************************************/ -/* Cortex-M0+ Processor Interruption and Exception Handlers */ -/******************************************************************************/ -/** - * @brief This function handles Non maskable interrupt. - */ -void NMI_Handler(void) -{ - /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ - - /* USER CODE END NonMaskableInt_IRQn 0 */ - /* USER CODE BEGIN NonMaskableInt_IRQn 1 */ - while (1) - { - } - /* USER CODE END NonMaskableInt_IRQn 1 */ -} - -/** - * @brief This function handles Hard fault interrupt. - */ -void HardFault_Handler(void) -{ - /* USER CODE BEGIN HardFault_IRQn 0 */ - - /* USER CODE END HardFault_IRQn 0 */ - while (1) - { - /* USER CODE BEGIN W1_HardFault_IRQn 0 */ - /* USER CODE END W1_HardFault_IRQn 0 */ - } -} - -/** - * @brief This function handles System service call via SWI instruction. - */ -void SVC_Handler(void) -{ - /* USER CODE BEGIN SVC_IRQn 0 */ - - /* USER CODE END SVC_IRQn 0 */ - /* USER CODE BEGIN SVC_IRQn 1 */ - - /* USER CODE END SVC_IRQn 1 */ -} - -/** - * @brief This function handles Pendable request for system service. - */ -void PendSV_Handler(void) -{ - /* USER CODE BEGIN PendSV_IRQn 0 */ - - /* USER CODE END PendSV_IRQn 0 */ - /* USER CODE BEGIN PendSV_IRQn 1 */ - - /* USER CODE END PendSV_IRQn 1 */ -} - -/** - * @brief This function handles System tick timer. - */ -void SysTick_Handler(void) -{ - /* USER CODE BEGIN SysTick_IRQn 0 */ - - /* USER CODE END SysTick_IRQn 0 */ - HAL_IncTick(); - /* USER CODE BEGIN SysTick_IRQn 1 */ - - /* USER CODE END SysTick_IRQn 1 */ -} - -/******************************************************************************/ -/* STM32L0xx Peripheral Interrupt Handlers */ -/* Add here the Interrupt Handlers for the used peripherals. */ -/* For the available peripheral interrupt handler names, */ -/* please refer to the startup file (startup_stm32l0xx.s). */ -/******************************************************************************/ - -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/Core/Src/syscalls.c b/Core/Src/syscalls.c deleted file mode 100644 index 914f768..0000000 --- a/Core/Src/syscalls.c +++ /dev/null @@ -1,207 +0,0 @@ -/** -***************************************************************************** -** -** File : syscalls.c -** -** Author : Auto-generated by System workbench for STM32 -** -** Abstract : System Workbench Minimal System calls file -** -** For more information about which c-functions -** need which of these lowlevel functions -** please consult the Newlib libc-manual -** -** Target : STMicroelectronics STM32 -** -** Distribution: The file is distributed “as is,” without any warranty -** of any kind. -** -***************************************************************************** -** @attention -** -**

© COPYRIGHT(c) 2019 STMicroelectronics

-** -** Redistribution and use in source and binary forms, with or without modification, -** are permitted provided that the following conditions are met: -** 1. Redistributions of source code must retain the above copyright notice, -** this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright notice, -** this list of conditions and the following disclaimer in the documentation -** and/or other materials provided with the distribution. -** 3. Neither the name of STMicroelectronics nor the names of its contributors -** may be used to endorse or promote products derived from this software -** without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -** -***************************************************************************** -*/ - -/* Includes */ -#include -#include -#include -#include -#include -#include -#include -#include - - -/* Variables */ -//#undef errno -extern int errno; -extern int __io_putchar(int ch) __attribute__((weak)); -extern int __io_getchar(void) __attribute__((weak)); - -register char * stack_ptr asm("sp"); - -char *__env[1] = { 0 }; -char **environ = __env; - - -/* Functions */ -void initialise_monitor_handles() -{ -} - -int _getpid(void) -{ - return 1; -} - -int _kill(int pid, int sig) -{ - errno = EINVAL; - return -1; -} - -void _exit (int status) -{ - _kill(status, -1); - while (1) {} /* Make sure we hang here */ -} - -__attribute__((weak)) int _read(int file, char *ptr, int len) -{ - int DataIdx; - - for (DataIdx = 0; DataIdx < len; DataIdx++) - { - *ptr++ = __io_getchar(); - } - -return len; -} - -__attribute__((weak)) int _write(int file, char *ptr, int len) -{ - int DataIdx; - - for (DataIdx = 0; DataIdx < len; DataIdx++) - { - __io_putchar(*ptr++); - } - return len; -} - -caddr_t _sbrk(int incr) -{ - extern char end asm("end"); - static char *heap_end; - char *prev_heap_end; - - if (heap_end == 0) - heap_end = &end; - - prev_heap_end = heap_end; - if (heap_end + incr > stack_ptr) - { -// write(1, "Heap and stack collision\n", 25); -// abort(); - errno = ENOMEM; - return (caddr_t) -1; - } - - heap_end += incr; - - return (caddr_t) prev_heap_end; -} - -int _close(int file) -{ - return -1; -} - - -int _fstat(int file, struct stat *st) -{ - st->st_mode = S_IFCHR; - return 0; -} - -int _isatty(int file) -{ - return 1; -} - -int _lseek(int file, int ptr, int dir) -{ - return 0; -} - -int _open(char *path, int flags, ...) -{ - /* Pretend like we always fail */ - return -1; -} - -int _wait(int *status) -{ - errno = ECHILD; - return -1; -} - -int _unlink(char *name) -{ - errno = ENOENT; - return -1; -} - -int _times(struct tms *buf) -{ - return -1; -} - -int _stat(char *file, struct stat *st) -{ - st->st_mode = S_IFCHR; - return 0; -} - -int _link(char *old, char *new) -{ - errno = EMLINK; - return -1; -} - -int _fork(void) -{ - errno = EAGAIN; - return -1; -} - -int _execve(char *name, char **argv, char **env) -{ - errno = ENOMEM; - return -1; -} diff --git a/Core/Src/system_stm32l0xx.c b/Core/Src/system_stm32l0xx.c deleted file mode 100644 index 9189ed8..0000000 --- a/Core/Src/system_stm32l0xx.c +++ /dev/null @@ -1,275 +0,0 @@ -/** - ****************************************************************************** - * @file system_stm32l0xx.c - * @author MCD Application Team - * @brief CMSIS Cortex-M0+ Device Peripheral Access Layer System Source File. - * - * This file provides two functions and one global variable to be called from - * user application: - * - SystemInit(): This function is called at startup just after reset and - * before branch to main program. This call is made inside - * the "startup_stm32l0xx.s" file. - * - * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used - * by the user application to setup the SysTick - * timer or configure other parameters. - * - * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must - * be called whenever the core clock is changed - * during program execution. - * - * - ****************************************************************************** - * @attention - * - *

© Copyright(c) 2016 STMicroelectronics. - * All rights reserved.

- * - * This software component is licensed by ST under BSD 3-Clause license, - * the "License"; You may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * opensource.org/licenses/BSD-3-Clause - * - ****************************************************************************** - */ - -/** @addtogroup CMSIS - * @{ - */ - -/** @addtogroup stm32l0xx_system - * @{ - */ - -/** @addtogroup STM32L0xx_System_Private_Includes - * @{ - */ - -#include "stm32l0xx.h" - -#if !defined (HSE_VALUE) - #define HSE_VALUE ((uint32_t)8000000U) /*!< Value of the External oscillator in Hz */ -#endif /* HSE_VALUE */ - -#if !defined (MSI_VALUE) - #define MSI_VALUE ((uint32_t)2097152U) /*!< Value of the Internal oscillator in Hz*/ -#endif /* MSI_VALUE */ - -#if !defined (HSI_VALUE) - #define HSI_VALUE ((uint32_t)16000000U) /*!< Value of the Internal oscillator in Hz*/ -#endif /* HSI_VALUE */ - - -/** - * @} - */ - -/** @addtogroup STM32L0xx_System_Private_TypesDefinitions - * @{ - */ - -/** - * @} - */ - -/** @addtogroup STM32L0xx_System_Private_Defines - * @{ - */ -/************************* Miscellaneous Configuration ************************/ - -/* Note: Following vector table addresses must be defined in line with linker - configuration. */ -/*!< Uncomment the following line if you need to relocate the vector table - anywhere in Flash or Sram, else the vector table is kept at the automatic - remap of boot address selected */ -/* #define USER_VECT_TAB_ADDRESS */ - -#if defined(USER_VECT_TAB_ADDRESS) -/*!< Uncomment the following line if you need to relocate your vector Table - in Sram else user remap will be done in Flash. */ -/* #define VECT_TAB_SRAM */ -#if defined(VECT_TAB_SRAM) -#define VECT_TAB_BASE_ADDRESS SRAM_BASE /*!< Vector Table base address field. - This value must be a multiple of 0x200. */ -#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field. - This value must be a multiple of 0x200. */ -#else -#define VECT_TAB_BASE_ADDRESS FLASH_BASE /*!< Vector Table base address field. - This value must be a multiple of 0x200. */ -#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field. - This value must be a multiple of 0x200. */ -#endif /* VECT_TAB_SRAM */ -#endif /* USER_VECT_TAB_ADDRESS */ - -/******************************************************************************/ -/** - * @} - */ - -/** @addtogroup STM32L0xx_System_Private_Macros - * @{ - */ - -/** - * @} - */ - -/** @addtogroup STM32L0xx_System_Private_Variables - * @{ - */ - /* This variable is updated in three ways: - 1) by calling CMSIS function SystemCoreClockUpdate() - 2) by calling HAL API function HAL_RCC_GetHCLKFreq() - 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency - Note: If you use this function to configure the system clock; then there - is no need to call the 2 first functions listed above, since SystemCoreClock - variable is updated automatically. - */ - uint32_t SystemCoreClock = 2097152U; /* 32.768 kHz * 2^6 */ - const uint8_t AHBPrescTable[16] = {0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 1U, 2U, 3U, 4U, 6U, 7U, 8U, 9U}; - const uint8_t APBPrescTable[8] = {0U, 0U, 0U, 0U, 1U, 2U, 3U, 4U}; - const uint8_t PLLMulTable[9] = {3U, 4U, 6U, 8U, 12U, 16U, 24U, 32U, 48U}; - -/** - * @} - */ - -/** @addtogroup STM32L0xx_System_Private_FunctionPrototypes - * @{ - */ - -/** - * @} - */ - -/** @addtogroup STM32L0xx_System_Private_Functions - * @{ - */ - -/** - * @brief Setup the microcontroller system. - * @param None - * @retval None - */ -void SystemInit (void) -{ - /* Configure the Vector Table location add offset address ------------------*/ -#if defined (USER_VECT_TAB_ADDRESS) - SCB->VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */ -#endif /* USER_VECT_TAB_ADDRESS */ -} - -/** - * @brief Update SystemCoreClock variable according to Clock Register Values. - * The SystemCoreClock variable contains the core clock (HCLK), it can - * be used by the user application to setup the SysTick timer or configure - * other parameters. - * - * @note Each time the core clock (HCLK) changes, this function must be called - * to update SystemCoreClock variable value. Otherwise, any configuration - * based on this variable will be incorrect. - * - * @note - The system frequency computed by this function is not the real - * frequency in the chip. It is calculated based on the predefined - * constant and the selected clock source: - * - * - If SYSCLK source is MSI, SystemCoreClock will contain the MSI - * value as defined by the MSI range. - * - * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(*) - * - * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**) - * - * - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**) - * or HSI_VALUE(*) multiplied/divided by the PLL factors. - * - * (*) HSI_VALUE is a constant defined in stm32l0xx_hal.h file (default value - * 16 MHz) but the real value may vary depending on the variations - * in voltage and temperature. - * - * (**) HSE_VALUE is a constant defined in stm32l0xx_hal.h file (default value - * 8 MHz), user has to ensure that HSE_VALUE is same as the real - * frequency of the crystal used. Otherwise, this function may - * have wrong result. - * - * - The result of this function could be not correct when using fractional - * value for HSE crystal. - * @param None - * @retval None - */ -void SystemCoreClockUpdate (void) -{ - uint32_t tmp = 0U, pllmul = 0U, plldiv = 0U, pllsource = 0U, msirange = 0U; - - /* Get SYSCLK source -------------------------------------------------------*/ - tmp = RCC->CFGR & RCC_CFGR_SWS; - - switch (tmp) - { - case 0x00U: /* MSI used as system clock */ - msirange = (RCC->ICSCR & RCC_ICSCR_MSIRANGE) >> RCC_ICSCR_MSIRANGE_Pos; - SystemCoreClock = (32768U * (1U << (msirange + 1U))); - break; - case 0x04U: /* HSI used as system clock */ - if ((RCC->CR & RCC_CR_HSIDIVF) != 0U) - { - SystemCoreClock = HSI_VALUE / 4U; - } - else - { - SystemCoreClock = HSI_VALUE; - } - break; - case 0x08U: /* HSE used as system clock */ - SystemCoreClock = HSE_VALUE; - break; - default: /* PLL used as system clock */ - /* Get PLL clock source and multiplication factor ----------------------*/ - pllmul = RCC->CFGR & RCC_CFGR_PLLMUL; - plldiv = RCC->CFGR & RCC_CFGR_PLLDIV; - pllmul = PLLMulTable[(pllmul >> RCC_CFGR_PLLMUL_Pos)]; - plldiv = (plldiv >> RCC_CFGR_PLLDIV_Pos) + 1U; - - pllsource = RCC->CFGR & RCC_CFGR_PLLSRC; - - if (pllsource == 0x00U) - { - /* HSI oscillator clock selected as PLL clock entry */ - if ((RCC->CR & RCC_CR_HSIDIVF) != 0U) - { - SystemCoreClock = (((HSI_VALUE / 4U) * pllmul) / plldiv); - } - else - { - SystemCoreClock = (((HSI_VALUE) * pllmul) / plldiv); - } - } - else - { - /* HSE selected as PLL clock entry */ - SystemCoreClock = (((HSE_VALUE) * pllmul) / plldiv); - } - break; - } - /* Compute HCLK clock frequency --------------------------------------------*/ - /* Get HCLK prescaler */ - tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> RCC_CFGR_HPRE_Pos)]; - /* HCLK clock frequency */ - SystemCoreClock >>= tmp; -} - - - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/Core/Src/usart.c b/Core/Src/usart.c deleted file mode 100644 index e6948fb..0000000 --- a/Core/Src/usart.c +++ /dev/null @@ -1,108 +0,0 @@ -/** - ****************************************************************************** - * @file usart.c - * @brief This file provides code for the configuration - * of the USART instances. - ****************************************************************************** - * @attention - * - *

© Copyright (c) 2021 STMicroelectronics. - * All rights reserved.

- * - * This software component is licensed by ST under BSD 3-Clause license, - * the "License"; You may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * opensource.org/licenses/BSD-3-Clause - * - ****************************************************************************** - */ - -/* Includes ------------------------------------------------------------------*/ -#include "usart.h" - -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ - -UART_HandleTypeDef huart2; - -/* USART2 init function */ - -void MX_USART2_UART_Init(void) -{ - - huart2.Instance = USART2; - huart2.Init.BaudRate = 115200; - huart2.Init.WordLength = UART_WORDLENGTH_8B; - huart2.Init.StopBits = UART_STOPBITS_1; - huart2.Init.Parity = UART_PARITY_NONE; - huart2.Init.Mode = UART_MODE_TX_RX; - huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE; - huart2.Init.OverSampling = UART_OVERSAMPLING_16; - huart2.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE; - huart2.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT; - if (HAL_UART_Init(&huart2) != HAL_OK) - { - Error_Handler(); - } - -} - -void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle) -{ - - GPIO_InitTypeDef GPIO_InitStruct = {0}; - if(uartHandle->Instance==USART2) - { - /* USER CODE BEGIN USART2_MspInit 0 */ - - /* USER CODE END USART2_MspInit 0 */ - /* USART2 clock enable */ - __HAL_RCC_USART2_CLK_ENABLE(); - - __HAL_RCC_GPIOA_CLK_ENABLE(); - /**USART2 GPIO Configuration - PA2 ------> USART2_TX - PA3 ------> USART2_RX - */ - GPIO_InitStruct.Pin = USART_TX_Pin|USART_RX_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.Alternate = GPIO_AF4_USART2; - HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /* USER CODE BEGIN USART2_MspInit 1 */ - - /* USER CODE END USART2_MspInit 1 */ - } -} - -void HAL_UART_MspDeInit(UART_HandleTypeDef* uartHandle) -{ - - if(uartHandle->Instance==USART2) - { - /* USER CODE BEGIN USART2_MspDeInit 0 */ - - /* USER CODE END USART2_MspDeInit 0 */ - /* Peripheral clock disable */ - __HAL_RCC_USART2_CLK_DISABLE(); - - /**USART2 GPIO Configuration - PA2 ------> USART2_TX - PA3 ------> USART2_RX - */ - HAL_GPIO_DeInit(GPIOA, USART_TX_Pin|USART_RX_Pin); - - /* USER CODE BEGIN USART2_MspDeInit 1 */ - - /* USER CODE END USART2_MspDeInit 1 */ - } -} - -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ -- cgit v1.2.3