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 - Project Level
- Integrate BSL dummy fct. to our main.cpp - Integrate BSL dummy fct. to our main.cpp
24.10.21 Helpfull links
https://www.mankier.com/1/st-flash#Options INTERFACES:
- pin
fun with Linus and why he only wants C - pin.h Updated with a header infromation "header" and missing function have benn added.
https://www.realworldtech.com/forum/?threadid=104196&curpostid=104299 - 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
erasing flash - USART
- we need to check what are the standart USART funtinalities and implement them all.
```st-flash erase``` - 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_ #ifndef _GPIO_H_
#define _GPIO_H_ #define _GPIO_H_
@ -62,7 +81,7 @@ typedef enum
floating, floating,
pushPull, pushPull,
openDrain openDrain
}state; }stage;
typedef enum typedef enum
{ {
@ -88,7 +107,7 @@ typedef enum
typedef struct typedef struct
{ {
mode md; mode md;
state st; stage st;
pullUpDown pud; pullUpDown pud;
speed sp; speed sp;
interrupt intr; interrupt intr;
@ -110,20 +129,39 @@ typedef enum
NotGpio NotGpio
}errors; }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 pinSetMode(pinNo_t pinNo, mode mode);
void pinSetOutputState(pinNo_t pinNo, state state); // Output Stage Push-Pull High-z ect...
void pinSetPullUpDonw(pinNo_t pinNo, pullUpDown resistance); 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 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); uint8_t pinRead(pinNo_t pinNo);
// Toggles th pin's value
void pinToggle(pinNo_t pinNo); void pinToggle(pinNo_t pinNo);
// Sets the pin hihg or low.
void pinWrite(pinNo_t pinNo, uint8_t state); void pinWrite(pinNo_t pinNo, uint8_t state);
// Initiates all the preriferals needed for the given pin
void pinInit(pinNo_t pinNo); void pinInit(pinNo_t pinNo);
// Deactivates all the preriferals needed for the given pin
void pinDeInit(pinNo_t pinNo); 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); 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(); void pinThrowError();
#ifdef __cplusplus #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_ #ifndef _USART_H_
#define _USART_H_ #define _USART_H_

@ -45,7 +45,7 @@ const uint32_t speedList[4] = {
OSPEEDR_HIGH OSPEEDR_HIGH
}; };
const uint32_t outputStateList[3] = const uint32_t outputStgeList[3] =
{ {
OTYPER_OPEN_DRAIN, OTYPER_OPEN_DRAIN,
OTYPER_PUSH_PULL, OTYPER_PUSH_PULL,
@ -60,10 +60,10 @@ void pinSetMode(pinNo_t pinNo, mode mode)
PIN_BASE->MODER |= (moderMode[mode] << ((pinNo & 0x0F) * 2)); 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 &= 1 << (pinNo & 0x0F);
PIN_BASE->OSPEEDR |= (outputStateList[state] << (pinNo & 0x0F)); PIN_BASE->OSPEEDR |= (outputStgeList[stage] << (pinNo & 0x0F));
} }
void pinSetPullUpDonw(pinNo_t pinNo, pullUpDown resistance) 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)); 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); pinSetMode(pinNo, mode);
pinSetOutputState(pinNo, state); pinSetOutputStage(pinNo, stage);
pinSetPullUpDonw(pinNo, resistance); pinSetPullUpDonw(pinNo, resistance);
pinSetSpeed(pinNo,speed); pinSetSpeed(pinNo,speed);
} }

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

Loading…
Cancel
Save