finish devleop can interface not yet tested
This commit is contained in:
70
306-controller_interface.X/app/factory/factory.c
Normal file
70
306-controller_interface.X/app/factory/factory.c
Normal file
@ -0,0 +1,70 @@
|
||||
#include "factory.h"
|
||||
|
||||
|
||||
//the factory object containing all objects of our system
|
||||
static Factory theFactory;
|
||||
|
||||
//all the getters
|
||||
LED* l1() {
|
||||
return &theFactory.l1_;
|
||||
}
|
||||
LED* l2() {
|
||||
return &theFactory.l2_;
|
||||
}
|
||||
LED* l3() {
|
||||
return &theFactory.l3_;
|
||||
}
|
||||
LED* l4() {
|
||||
return &theFactory.l4_;
|
||||
}
|
||||
LED* l5() {
|
||||
return &theFactory.l5_;
|
||||
}
|
||||
LED* l6() {
|
||||
return &theFactory.l6_;
|
||||
}
|
||||
LED* l7() {
|
||||
return &theFactory.l7_;
|
||||
}
|
||||
LED* l8() {
|
||||
return &theFactory.l8_;
|
||||
}
|
||||
|
||||
|
||||
//initialize all objects
|
||||
void Factory_init() {
|
||||
LED_init(l1(), 1);
|
||||
LED_init(l2(), 2);
|
||||
LED_init(l3(), 3);
|
||||
LED_init(l4(), 4);
|
||||
LED_init(l5(), 5);
|
||||
LED_init(l6(), 6);
|
||||
LED_init(l7(), 7);
|
||||
LED_init(l8(), 8);
|
||||
|
||||
LED_initHW(l1());
|
||||
LED_initHW(l2());
|
||||
LED_initHW(l3());
|
||||
LED_initHW(l4());
|
||||
LED_initHW(l5());
|
||||
LED_initHW(l6());
|
||||
LED_initHW(l7());
|
||||
LED_initHW(l8());
|
||||
|
||||
CAN_init();
|
||||
}
|
||||
|
||||
void foo(uint8_t a, uint8_t b, uint32_t c){
|
||||
|
||||
}
|
||||
|
||||
//connect objects if required
|
||||
void Factory_build() {
|
||||
ECAN_SetRXBnInterruptHandler(CAN_newMsg);
|
||||
CAN_onReceiveCan(foo);
|
||||
}
|
||||
|
||||
//start all state machines
|
||||
void Factory_start() {
|
||||
CAN_startBehaviour();
|
||||
}
|
48
306-controller_interface.X/app/factory/factory.h
Normal file
48
306-controller_interface.X/app/factory/factory.h
Normal file
@ -0,0 +1,48 @@
|
||||
/**
|
||||
* @author R<>mi Heredero
|
||||
* @version. 0.0.0
|
||||
* @date August 2023
|
||||
* @file factory.h
|
||||
*/
|
||||
|
||||
|
||||
#ifndef FACTORY_H
|
||||
#define FACTORY_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "../../board/led/led.h"
|
||||
#include "../../board/button/button.h"
|
||||
#include "../../middleware/can_interface.h"
|
||||
|
||||
|
||||
typedef struct {
|
||||
LED l1_;
|
||||
LED l2_;
|
||||
LED l3_;
|
||||
LED l4_;
|
||||
LED l5_;
|
||||
LED l6_;
|
||||
LED l7_;
|
||||
LED l8_;
|
||||
|
||||
} Factory;
|
||||
|
||||
|
||||
void Factory_init();
|
||||
void Factory_build();
|
||||
void Factory_start();
|
||||
|
||||
//these are global getters for our objects
|
||||
LED* l1();
|
||||
LED* l2();
|
||||
LED* l3();
|
||||
LED* l4();
|
||||
LED* l5();
|
||||
LED* l6();
|
||||
LED* l7();
|
||||
LED* l8();
|
||||
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user