finish devleop can interface not yet tested

This commit is contained in:
2023-08-23 13:45:34 +02:00
parent ff9137a026
commit 21f9cb7f62
23 changed files with 927 additions and 1144 deletions

View File

@ -1,8 +1,13 @@
/**
* @author R<>mi Heredero (remi@heredero.ch)
* @version. 1.0.0
* @date 2023-06-15
*/
#include "led.h"
#include "../../mcc_generated_files/pin_manager.h"
void LED_init(LED* me, uint8_t id)
{
void LED_init(LED* me, uint8_t id) {
me->id = id;
}
@ -10,94 +15,68 @@ void LED_init(LED* me, uint8_t id)
* @brief Initialize the Driver
*
*/
void LED_initHW(LED* me)
{
void LED_initHW(LED* me) {
LED_off(me);
}
/*
* for the on and the off methods:
* if the output is push pull, it depends if the
* load is connect to ground or vcc.
* in this case, the load is connected to vcc,
* so on and off are inverted. Change the code as it
* is convenient for your hardware
*/
//switch on the led
//maybe you have to adjust your
//low level calls
void LED_on(LED* me)
{
switch (me->id)
{
void LED_on(void* me) {
LED* l = (LED*) me;
switch (l->id) {
case 1:
IO_RB0_SetLow();
OUTPUT1_SetHigh();
break;
case 2:
OUTPUT2_SetHigh();
break;
case 3:
OUTPUT3_SetHigh();
break;
case 4:
OUTPUT4_SetHigh();
break;
case 5:
OUTPUT5_SetHigh();
break;
case 6:
OUTPUT6_SetHigh();
break;
case 7:
OUTPUT7_SetHigh();
break;
case 8:
break;
case 9:
break;
case 10:
break;
OUTPUT8_SetHigh();
break;
}
}
//switch off the led
//maybe you have to adjust your
//low level calls
void LED_off(LED* me)
{
switch (me->id)
{
void LED_off(void* me) {
LED* l = (LED*) me;
switch (l->id) {
case 1:
IO_RB0_SetHigh();
OUTPUT1_SetLow();
break;
case 2:
OUTPUT2_SetLow();
break;
case 3:
OUTPUT3_SetLow();
break;
case 4:
OUTPUT4_SetLow();
break;
case 5:
OUTPUT5_SetLow();
break;
case 6:
OUTPUT6_SetLow();
break;
case 7:
OUTPUT7_SetLow();
break;
case 8:
break;
case 9:
break;
case 10:
OUTPUT8_SetLow();
break;
}
}
}
void LED_setState(LED* me, uint8_t state)
{
if (state == HIGH)
{
LED_on(me);
}
if (state == LOW)
{
LED_off(me);
}
}

View File

@ -1,23 +1,43 @@
#ifndef LED_ONCE
#define LED_ONCE
/**
* @author R<>mi Heredero (remi@heredero.ch)
* @version. 1.0.0
* @date 2023-06-15
*/
#ifndef LED_H
#define LED_H
#include <stdint.h>
/*
* this is the declaration of the Led class
// LED struct
typedef struct {
uint8_t id; // The id of the LED
}LED;
/**
* Initialize the led
* @param me the led itself
* @param id the id of the led
*/
struct LED_
{
//has a gpo
uint8_t id;
};
typedef struct LED_ LED;
void LED_init(LED* me, uint8_t id);
void LED_initHW(LED* me);
void LED_on(LED* me);
void LED_off(LED* me);
void LED_setState(LED* me,uint8_t state);
#endif
/**
* Initializing the led
* @param me the led itself
*/
void LED_initHW(LED* me);
/**
* Turn On the led
* @param me the led itself
*/
void LED_on(void* me);
/**
* Turn Off the led
* @param me the led itself
*/
void LED_off(void* me);
#endif /* LED_H */