Finalised the pin.h implmentation with missing functions. started with usart.h updated the Readme

interrupts
key 4 years ago
parent 8c67198b08
commit 8eebbc2fa4

@ -14,13 +14,20 @@ Kerems and Edwins Develeppoment platform.
- Project Level
- Integrate BSL dummy fct. to our main.cpp
24.10.21 Helpfull links
https://www.mankier.com/1/st-flash#Options
fun with Linus and why he only wants C
https://www.realworldtech.com/forum/?threadid=104196&curpostid=104299
erasing flash
```st-flash erase```
INTERFACES:
- pin
- pin.h Updated with a header infromation "header" and missing function have benn added.
- pin.h Is tagged wiht version 1.0 and will be concidered as the first stalbe implementation
- pin.h will also be used by other interfaces when they need to initiate alternate functions
- USART
- we need to check what are the standart USART funtinalities and implement them all.
- usart.h the first implmentation will be made to make sure thte we have a working basis.
DOCUMANTATION:
- STM-Flash utility
- https://www.mankier.com/1/st-flash#Options
- erasing flash ```st-flash erase```
- Fun with Linus and why he only wants C
- https://www.realworldtech.com/forum/?threadid=104196&curpostid=104299

@ -1,3 +1,22 @@
/************************************************************************************************
* Authors : Kerem Yollu & Edwin Koch
* Date : 01.11.2021
* Version : 1.0
*
* Description :
* This header file for pin control is based on the most common configuation options
* curenty awailable for modern hardware.
* Depending of the used Chip, some function may vary or be unawailable.
* Please take a minute to go and explore the according Chips pin.c file to see woh each function
* is implmented.
*
* TODO:
* - 01.11.2021 : Should we add a seprate header in the cls layer containing the pinNo_t ?
* - 01.11.2021 : Depending on request implment a pinLock() function
*
* LICENCE : Please check the end of this file
************************************************************************************************/
#ifndef _GPIO_H_
#define _GPIO_H_
@ -62,7 +81,7 @@ typedef enum
floating,
pushPull,
openDrain
}state;
}stage;
typedef enum
{
@ -88,7 +107,7 @@ typedef enum
typedef struct
{
mode md;
state st;
stage st;
pullUpDown pud;
speed sp;
interrupt intr;
@ -110,20 +129,39 @@ typedef enum
NotGpio
}errors;
// Configuration function that will call all the necessary function for an sucessfull pin initialisation
void pinConfig(pinNo_t pinNo, mode mode, stage stage, pullUpDown resistance, speed speed);
// Modes to set the direction or function of the pin
void pinSetMode(pinNo_t pinNo, mode mode);
void pinSetOutputState(pinNo_t pinNo, state state);
void pinSetPullUpDonw(pinNo_t pinNo, pullUpDown resistance);
// Output Stage Push-Pull High-z ect...
void pinSetOutputStage(pinNo_t pinNo, stage stage);
// Depending of the hardare it is able to select the speed of given pins
void pinSetSpeed(pinNo_t pinNo, speed speed);
void pinConfig(pinNo_t pinNo, mode mode, state state, pullUpDown resistance, speed speed);
// If internal Pull-up or Pull-donws are wailable
void pinSetPullUpDonw(pinNo_t pinNo, pullUpDown resistance);
// If pin is set as alternate this function will modify the pins functionality
// If pin isn't set as alternate this function will set the pin to alternate mode.
void pinSetAlternate(pinNo_t pinNo, uint16_t alternate);
// Reads the pin's current value
uint8_t pinRead(pinNo_t pinNo);
// Toggles th pin's value
void pinToggle(pinNo_t pinNo);
// Sets the pin hihg or low.
void pinWrite(pinNo_t pinNo, uint8_t state);
// Initiates all the preriferals needed for the given pin
void pinInit(pinNo_t pinNo);
// Deactivates all the preriferals needed for the given pin
void pinDeInit(pinNo_t pinNo);
// Resets pin to default
void pinReset(pinNo_t pinNo);
// Dependeing on the platform an the form of information printing.
// Will pirnt tthe rurrent devices pin status and their configrarion.
void pinHardwareInfo(pinNo_t pinNo);
// Dependeing on the platfonr an the form of information printing.
// Handles the given error and stops all further execution.
void pinThrowError();
#ifdef __cplusplus

@ -1,3 +1,14 @@
/************************************************************************************************
* Authors : Kerem Yollu & Edwin Koch
* Date : 31.11.2021
* Version : 1.0
*
* Description :
*
* TODO:
*
* LICENCE : Please check the end of this file
************************************************************************************************/
#ifndef _USART_H_
#define _USART_H_

@ -1,6 +1,6 @@
#include "pin.h"
#define MODER_IN 0x0UL
#define MODER_IN 0x0UL
#define MODER_OUT 0x1UL
#define MODER_ALTERNATE 0x2UL
#define MODER_ANALOG 0x3UL
@ -45,7 +45,7 @@ const uint32_t speedList[4] = {
OSPEEDR_HIGH
};
const uint32_t outputStateList[3] =
const uint32_t outputStgeList[3] =
{
OTYPER_OPEN_DRAIN,
OTYPER_PUSH_PULL,
@ -60,10 +60,10 @@ void pinSetMode(pinNo_t pinNo, mode mode)
PIN_BASE->MODER |= (moderMode[mode] << ((pinNo & 0x0F) * 2));
}
void pinSetOutputState(pinNo_t pinNo, state state)
void pinSetOutputStage(pinNo_t pinNo, stage stage)
{
PIN_BASE->OSPEEDR &= 1 << (pinNo & 0x0F);
PIN_BASE->OSPEEDR |= (outputStateList[state] << (pinNo & 0x0F));
PIN_BASE->OSPEEDR |= (outputStgeList[stage] << (pinNo & 0x0F));
}
void pinSetPullUpDonw(pinNo_t pinNo, pullUpDown resistance)
@ -78,11 +78,11 @@ void pinSetSpeed(pinNo_t pinNo, speed speed)
PIN_BASE->OSPEEDR |= (speedList[speed] << ((pinNo & 0x0F) * 2));
}
void pinConfig(pinNo_t pinNo, mode mode, state state, pullUpDown resistance, speed speed)
void pinConfig(pinNo_t pinNo, mode mode, stage stage, pullUpDown resistance, speed speed)
{
pinInit(pinNo);
pinInit(pinNo); //Very important to init first so that the corresponding bus gets his clock
pinSetMode(pinNo, mode);
pinSetOutputState(pinNo, state);
pinSetOutputStage(pinNo, stage);
pinSetPullUpDonw(pinNo, resistance);
pinSetSpeed(pinNo,speed);
}

@ -88,7 +88,7 @@ int stmStart()
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
// MX_GPIO_Init();
//MX_GPIO_Init();
/* USER CODE BEGIN 2 */
/* USER CODE END 2 */
@ -97,7 +97,7 @@ int stmStart()
// while (1)
// {
/* USER CODE END WHILE */
// LL_GPIO_TogglePin(LED_G_GPIO_Port,LED_G_Pin);
//LL_GPIO_TogglePin(LED_G_GPIO_Port,LED_G_Pin);
// LL_mDelay(100);
/* USER CODE BEGIN 3 */
// }

@ -23,6 +23,7 @@ int main(int argc, char *argv[])
while(1)
{
if(pinRead(pinA0))
{
pinWrite(pinB3,1);
@ -31,8 +32,8 @@ int main(int argc, char *argv[])
{
pinWrite(pinB3,0);
}
}
}
return 1;
}

Loading…
Cancel
Save