Merge pull request #2 from SummerSchool2023-RED/harmonisation
Harmonisation
This commit is contained in:
commit
2b91ec2df0
@ -52,10 +52,17 @@ void Factory_init() {
|
||||
LED_initHW(l8());
|
||||
|
||||
CAN_init();
|
||||
CAN_setSender(1);
|
||||
LED_off(l1());
|
||||
}
|
||||
|
||||
void foo(uint8_t a, uint8_t b, uint32_t c){
|
||||
|
||||
if(b){
|
||||
LED_on(l1());
|
||||
} else {
|
||||
LED_off(l1());
|
||||
}
|
||||
CAN_Send(a, b, c);
|
||||
}
|
||||
|
||||
//connect objects if required
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "../mcc_generated_files/mcc.h"
|
||||
#include "../xf/xf.h"
|
||||
#include "factory/factory.h"
|
||||
#include "mcc_generated_files/mcc.h"
|
||||
#include "xf/xf.h"
|
||||
#include "app/factory/factory.h"
|
||||
|
||||
/*
|
||||
* the main function
|
@ -14,7 +14,7 @@
|
||||
This header file provides implementations for driver APIs for all modules selected in the GUI.
|
||||
Generation Information :
|
||||
Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8
|
||||
Device : PIC18F26K83
|
||||
Device : PIC18F25K83
|
||||
Driver Version : 2.00
|
||||
The generated drivers are tested against the following:
|
||||
Compiler : XC8 2.36 and above or later
|
||||
|
@ -14,7 +14,7 @@
|
||||
This header file provides implementations for driver APIs for all modules selected in the GUI.
|
||||
Generation Information :
|
||||
Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8
|
||||
Device : PIC18F26K83
|
||||
Device : PIC18F25K83
|
||||
Driver Version : 2.00
|
||||
The generated drivers are tested against the following:
|
||||
Compiler : XC8 2.36 and above or later
|
||||
|
@ -13,12 +13,12 @@
|
||||
@Description
|
||||
This source file provides APIs for CAN.
|
||||
Generation Information :
|
||||
Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.7
|
||||
Device : PIC18F26K83
|
||||
Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8
|
||||
Device : PIC18F25K83
|
||||
Driver Version : 3.0.0
|
||||
The generated drivers are tested against the following:
|
||||
Compiler : XC8 2.31 and above
|
||||
MPLAB : MPLAB X 5.45
|
||||
Compiler : XC8 2.36 and above
|
||||
MPLAB : MPLAB X 6.00
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@ -16,7 +16,7 @@
|
||||
all modules selected in the GUI.
|
||||
Generation Information :
|
||||
Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8
|
||||
Device : PIC18F26K83
|
||||
Device : PIC18F25K83
|
||||
Driver Version : 2.04
|
||||
The generated drivers are tested against the following:
|
||||
Compiler : XC8 2.36 and above or later
|
||||
|
@ -16,7 +16,7 @@
|
||||
all modules selected in the GUI.
|
||||
Generation Information :
|
||||
Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8
|
||||
Device : PIC18F26K83
|
||||
Device : PIC18F25K83
|
||||
Driver Version : 2.03
|
||||
The generated drivers are tested against the following:
|
||||
Compiler : XC8 2.36 and above or later
|
||||
|
@ -14,7 +14,7 @@
|
||||
This header file provides implementations for driver APIs for all modules selected in the GUI.
|
||||
Generation Information :
|
||||
Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8
|
||||
Device : PIC18F26K83
|
||||
Device : PIC18F25K83
|
||||
Driver Version : 2.00
|
||||
The generated drivers are tested against the following:
|
||||
Compiler : XC8 2.36 and above or later
|
||||
|
@ -14,7 +14,7 @@
|
||||
This header file provides implementations for driver APIs for all modules selected in the GUI.
|
||||
Generation Information :
|
||||
Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8
|
||||
Device : PIC18F26K83
|
||||
Device : PIC18F25K83
|
||||
Driver Version : 2.00
|
||||
The generated drivers are tested against the following:
|
||||
Compiler : XC8 2.36 and above or later
|
||||
|
@ -14,7 +14,7 @@
|
||||
This file provides implementations of driver APIs for MEMORY.
|
||||
Generation Information :
|
||||
Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8
|
||||
Device : PIC18F26K83
|
||||
Device : PIC18F25K83
|
||||
Driver Version : 2.1.3
|
||||
The generated drivers are tested against the following:
|
||||
Compiler : XC8 2.36 and above
|
||||
|
@ -14,7 +14,7 @@
|
||||
This header file provides APIs for driver for MEMORY.
|
||||
Generation Information :
|
||||
Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8
|
||||
Device : PIC18F26K83
|
||||
Device : PIC18F25K83
|
||||
Driver Version : 2.1.3
|
||||
The generated drivers are tested against the following:
|
||||
Compiler : XC8 2.36 and above
|
||||
@ -64,9 +64,9 @@
|
||||
Section: Macro Declarations
|
||||
*/
|
||||
|
||||
#define WRITE_FLASH_BLOCKSIZE 128
|
||||
#define ERASE_FLASH_BLOCKSIZE 128
|
||||
#define END_FLASH 0x010000
|
||||
#define WRITE_FLASH_BLOCKSIZE 64
|
||||
#define ERASE_FLASH_BLOCKSIZE 64
|
||||
#define END_FLASH 0x008000
|
||||
|
||||
/**
|
||||
Section: Flash Module APIs
|
||||
|
@ -14,7 +14,7 @@
|
||||
This header file provides implementations for pin APIs for all pins selected in the GUI.
|
||||
Generation Information :
|
||||
Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8
|
||||
Device : PIC18F26K83
|
||||
Device : PIC18F25K83
|
||||
Driver Version : 2.11
|
||||
The generated drivers are tested against the following:
|
||||
Compiler : XC8 2.36 and above
|
||||
|
@ -14,7 +14,7 @@
|
||||
This header file provides APIs for driver for .
|
||||
Generation Information :
|
||||
Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8
|
||||
Device : PIC18F26K83
|
||||
Device : PIC18F25K83
|
||||
Driver Version : 2.11
|
||||
The generated drivers are tested against the following:
|
||||
Compiler : XC8 2.36 and above
|
||||
|
@ -14,7 +14,7 @@
|
||||
This source file provides APIs for TMR0.
|
||||
Generation Information :
|
||||
Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8
|
||||
Device : PIC18F26K83
|
||||
Device : PIC18F25K83
|
||||
Driver Version : 3.10
|
||||
The generated drivers are tested against the following:
|
||||
Compiler : XC8 2.36 and above
|
||||
|
@ -14,7 +14,7 @@
|
||||
This header file provides APIs for TMR0.
|
||||
Generation Information :
|
||||
Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8
|
||||
Device : PIC18F26K83
|
||||
Device : PIC18F25K83
|
||||
Driver Version : 3.10
|
||||
The generated drivers are tested against the following:
|
||||
Compiler : XC8 2.36 and above
|
||||
|
@ -36,20 +36,20 @@ bool ALIVE_CHECKER_processEvent(Event* ev) {
|
||||
break;
|
||||
|
||||
case STAC_SETUP:
|
||||
if (ev->id = evACborn) {
|
||||
if (ev->id == evACborn) {
|
||||
me->state = STAC_BORN;
|
||||
}
|
||||
break;
|
||||
|
||||
case STAC_BORN:
|
||||
if (ev->id = evACready) {
|
||||
if (ev->id == evACready) {
|
||||
me->state = STAC_WAIT;
|
||||
ALIVE_CHECKER_emitPoll(me, me->aliveTime*10, 0);
|
||||
}
|
||||
break;
|
||||
|
||||
case STAC_WAIT:
|
||||
if (ev->id = evACpoll) {
|
||||
if (ev->id == evACpoll) {
|
||||
if (me->isAlive) {
|
||||
me->state = STAC_WAIT;
|
||||
ALIVE_CHECKER_emitPoll(me, me->aliveTime*10, 0);
|
||||
@ -60,7 +60,7 @@ bool ALIVE_CHECKER_processEvent(Event* ev) {
|
||||
break;
|
||||
|
||||
case STAC_DEAD:
|
||||
if(ev->id = evACborn) {
|
||||
if(ev->id == evACborn) {
|
||||
me->state = STAC_BORN;
|
||||
}
|
||||
break;
|
||||
|
@ -18,7 +18,7 @@ typedef enum {
|
||||
} ALIVE_CHECKER_STATES;
|
||||
|
||||
typedef enum {
|
||||
evACinit = 100, // TODO change this number (< 256)
|
||||
evACinit = 15,
|
||||
evACborn,
|
||||
evACready,
|
||||
evACpoll
|
||||
|
@ -6,6 +6,38 @@
|
||||
*/
|
||||
|
||||
#include "can_interface.h"
|
||||
#include "../mcc_generated_files/ecan.h"
|
||||
|
||||
|
||||
typedef union {
|
||||
struct {
|
||||
uint8_t sender;
|
||||
uint8_t recipient;
|
||||
uint8_t message;
|
||||
uint32_t data;
|
||||
} full;
|
||||
struct {
|
||||
uint8_t sender;
|
||||
uint8_t recipient;
|
||||
uint8_t message;
|
||||
uint8_t data0;
|
||||
uint8_t data1;
|
||||
uint8_t data2;
|
||||
uint8_t data3;
|
||||
} separate;
|
||||
} CAN_MESSAGE;
|
||||
|
||||
typedef union {
|
||||
struct {
|
||||
uint8_t byte0;
|
||||
uint8_t byte1;
|
||||
uint8_t byte2;
|
||||
uint8_t byte3;
|
||||
} separate;
|
||||
struct {
|
||||
uint32_t bytes;
|
||||
} full;
|
||||
} CAN_4_BYTES;
|
||||
|
||||
void CAN_init(){
|
||||
CAN_myself.receiveCan = NULL;
|
||||
@ -39,11 +71,13 @@ bool CAN_processEvent(Event* ev) {
|
||||
if (me->receiveCan != NULL) {
|
||||
uint32_t canData = (uint32_t) data;
|
||||
data = data>>32;
|
||||
uint8_t idMsg = (uint8_t) data;
|
||||
data = data>>4;
|
||||
uint8_t idRecipient = (uint8_t) data;
|
||||
data = data>>4;
|
||||
uint8_t idSender = (uint8_t) data;
|
||||
|
||||
CAN_4_BYTES tmpData;
|
||||
tmpData.full.bytes = data;
|
||||
uint8_t idMsg = 0x0F && (tmpData.separate.byte0>>4);
|
||||
uint8_t idRecipient = 0x0F && tmpData.separate.byte1;
|
||||
uint8_t idSender = (tmpData.separate.byte1>>4);
|
||||
|
||||
me->receiveCan(idSender, idMsg, canData);
|
||||
}
|
||||
}
|
||||
@ -54,13 +88,13 @@ bool CAN_processEvent(Event* ev) {
|
||||
canMsg.frame.idType = 0; // I don't understand what is it
|
||||
canMsg.frame.dlc = 4; // 4 bytes to send
|
||||
canMsg.frame.rtr = 0; // no remote frame
|
||||
canMsg.frame.data0 = (uint8_t) data;
|
||||
data = data >> 8;
|
||||
canMsg.frame.data1 = (uint8_t) data;
|
||||
canMsg.frame.data3 = (uint8_t) data;
|
||||
data = data >> 8;
|
||||
canMsg.frame.data2 = (uint8_t) data;
|
||||
data = data >> 8;
|
||||
canMsg.frame.data3 = (uint8_t) data;
|
||||
canMsg.frame.data1 = (uint8_t) data;
|
||||
data = data >> 8;
|
||||
canMsg.frame.data0 = (uint8_t) data;
|
||||
data = data >> 8;
|
||||
canMsg.frame.id = (uint32_t) data;
|
||||
CAN_transmit(&canMsg);
|
||||
@ -107,14 +141,14 @@ void CAN_newMsg() {
|
||||
uCAN_MSG canMsg;
|
||||
CAN_receive(&canMsg);
|
||||
data = canMsg.frame.id;
|
||||
data = data<<32;
|
||||
data = canMsg.frame.data0;
|
||||
data = data<<12;
|
||||
data = data | canMsg.frame.data0;
|
||||
data = data<<8;
|
||||
data = canMsg.frame.data1;
|
||||
data = data | canMsg.frame.data1;
|
||||
data = data<<8;
|
||||
data = canMsg.frame.data2;
|
||||
data = data | canMsg.frame.data2;
|
||||
data = data<<8;
|
||||
data = canMsg.frame.data3;
|
||||
data = data | canMsg.frame.data3;
|
||||
POST(&CAN_myself, &CAN_processEvent, evCAnewMsg, 0, data);
|
||||
}
|
||||
|
||||
@ -125,3 +159,11 @@ void CAN_Send(uint8_t idRecipient, uint8_t idMsg, uint32_t data) {
|
||||
tmpData = (tmpData<<32) | data;
|
||||
POST(&CAN_myself, &CAN_processEvent, evCAsend, 0, tmpData);
|
||||
}
|
||||
|
||||
/***********
|
||||
* SETTERS *
|
||||
***********/
|
||||
|
||||
void CAN_setSender(uint8_t idSender) {
|
||||
CAN_myself.sender = idSender;
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ typedef enum {
|
||||
} CAN_STATES;
|
||||
|
||||
typedef enum {
|
||||
evCAinit = 10, // TODO change this number (< 256)
|
||||
evCAinit = 10,
|
||||
evCAnewMsg,
|
||||
evCAsend
|
||||
} CAN_EVENTS;
|
||||
|
@ -41,7 +41,6 @@
|
||||
projectFiles="true">
|
||||
<logicalFolder name="app" displayName="app" projectFiles="true">
|
||||
<itemPath>app/factory/factory.c</itemPath>
|
||||
<itemPath>app/main.c</itemPath>
|
||||
</logicalFolder>
|
||||
<logicalFolder name="board" displayName="board" projectFiles="true">
|
||||
<itemPath>board/led/led.c</itemPath>
|
||||
@ -65,6 +64,7 @@
|
||||
<itemPath>xf/event.c</itemPath>
|
||||
<itemPath>xf/xf.c</itemPath>
|
||||
</logicalFolder>
|
||||
<itemPath>main.c</itemPath>
|
||||
</logicalFolder>
|
||||
<logicalFolder name="ExternalFiles"
|
||||
displayName="Important Files"
|
||||
@ -75,19 +75,14 @@
|
||||
</logicalFolder>
|
||||
</logicalFolder>
|
||||
<sourceRootList>
|
||||
<Elem>board</Elem>
|
||||
<Elem>led</Elem>
|
||||
<Elem>factory</Elem>
|
||||
<Elem>middleware</Elem>
|
||||
<Elem>app</Elem>
|
||||
<Elem>xf</Elem>
|
||||
<Elem>.</Elem>
|
||||
</sourceRootList>
|
||||
<projectmakefile>Makefile</projectmakefile>
|
||||
<confs>
|
||||
<conf name="default" type="2">
|
||||
<toolsSet>
|
||||
<developmentServer>localhost</developmentServer>
|
||||
<targetDevice>PIC18F26K83</targetDevice>
|
||||
<targetDevice>PIC18F25K83</targetDevice>
|
||||
<targetHeader></targetHeader>
|
||||
<targetPluginBoard></targetPluginBoard>
|
||||
<platformTool>PICkit3PlatformTool</platformTool>
|
||||
@ -245,7 +240,7 @@
|
||||
<property key="programoptions.programcalmem" value="false"/>
|
||||
<property key="programoptions.programuserotp" value="false"/>
|
||||
<property key="programoptions.testmodeentrymethod" value="VDDFirst"/>
|
||||
<property key="programoptions.usehighvoltageonmclr" value="false"/>
|
||||
<property key="programoptions.usehighvoltageonmclr" value="true"/>
|
||||
<property key="programoptions.uselvpprogramming" value="false"/>
|
||||
<property key="voltagevalue" value="5.0"/>
|
||||
</PICkit3PlatformTool>
|
||||
@ -290,7 +285,7 @@
|
||||
<property key="programoptions.programcalmem" value="false"/>
|
||||
<property key="programoptions.programuserotp" value="false"/>
|
||||
<property key="programoptions.testmodeentrymethod" value="VDDFirst"/>
|
||||
<property key="programoptions.usehighvoltageonmclr" value="false"/>
|
||||
<property key="programoptions.usehighvoltageonmclr" value="true"/>
|
||||
<property key="programoptions.uselvpprogramming" value="false"/>
|
||||
<property key="voltagevalue" value="5.0"/>
|
||||
</Tool>
|
||||
|
@ -13,12 +13,7 @@
|
||||
<sourceEncoding>ISO-8859-1</sourceEncoding>
|
||||
<make-dep-projects/>
|
||||
<sourceRootList>
|
||||
<sourceRootElem>board</sourceRootElem>
|
||||
<sourceRootElem>led</sourceRootElem>
|
||||
<sourceRootElem>factory</sourceRootElem>
|
||||
<sourceRootElem>middleware</sourceRootElem>
|
||||
<sourceRootElem>app</sourceRootElem>
|
||||
<sourceRootElem>xf</sourceRootElem>
|
||||
<sourceRootElem>.</sourceRootElem>
|
||||
</sourceRootList>
|
||||
<confList>
|
||||
<confElem>
|
||||
|
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user