Merge pull request #2 from SummerSchool2023-RED/harmonisation

Harmonisation
This commit is contained in:
Rémi Heredero 2023-08-24 20:33:05 +02:00 committed by GitHub
commit 2b91ec2df0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 144 additions and 109 deletions

View File

@ -52,10 +52,17 @@ void Factory_init() {
LED_initHW(l8()); LED_initHW(l8());
CAN_init(); CAN_init();
CAN_setSender(1);
LED_off(l1());
} }
void foo(uint8_t a, uint8_t b, uint32_t c){ 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 //connect objects if required

View File

@ -1,6 +1,6 @@
#include "../mcc_generated_files/mcc.h" #include "mcc_generated_files/mcc.h"
#include "../xf/xf.h" #include "xf/xf.h"
#include "factory/factory.h" #include "app/factory/factory.h"
/* /*
* the main function * the main function

View File

@ -14,7 +14,7 @@
This header file provides implementations for driver APIs for all modules selected in the GUI. This header file provides implementations for driver APIs for all modules selected in the GUI.
Generation Information : Generation Information :
Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8 Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8
Device : PIC18F26K83 Device : PIC18F25K83
Driver Version : 2.00 Driver Version : 2.00
The generated drivers are tested against the following: The generated drivers are tested against the following:
Compiler : XC8 2.36 and above or later Compiler : XC8 2.36 and above or later

View File

@ -14,7 +14,7 @@
This header file provides implementations for driver APIs for all modules selected in the GUI. This header file provides implementations for driver APIs for all modules selected in the GUI.
Generation Information : Generation Information :
Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8 Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8
Device : PIC18F26K83 Device : PIC18F25K83
Driver Version : 2.00 Driver Version : 2.00
The generated drivers are tested against the following: The generated drivers are tested against the following:
Compiler : XC8 2.36 and above or later Compiler : XC8 2.36 and above or later

View File

@ -13,12 +13,12 @@
@Description @Description
This source file provides APIs for CAN. This source file provides APIs for CAN.
Generation Information : Generation Information :
Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.7 Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8
Device : PIC18F26K83 Device : PIC18F25K83
Driver Version : 3.0.0 Driver Version : 3.0.0
The generated drivers are tested against the following: The generated drivers are tested against the following:
Compiler : XC8 2.31 and above Compiler : XC8 2.36 and above
MPLAB : MPLAB X 5.45 MPLAB : MPLAB X 6.00
*/ */
/* /*

View File

@ -16,7 +16,7 @@
all modules selected in the GUI. all modules selected in the GUI.
Generation Information : Generation Information :
Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8 Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8
Device : PIC18F26K83 Device : PIC18F25K83
Driver Version : 2.04 Driver Version : 2.04
The generated drivers are tested against the following: The generated drivers are tested against the following:
Compiler : XC8 2.36 and above or later Compiler : XC8 2.36 and above or later

View File

@ -16,7 +16,7 @@
all modules selected in the GUI. all modules selected in the GUI.
Generation Information : Generation Information :
Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8 Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8
Device : PIC18F26K83 Device : PIC18F25K83
Driver Version : 2.03 Driver Version : 2.03
The generated drivers are tested against the following: The generated drivers are tested against the following:
Compiler : XC8 2.36 and above or later Compiler : XC8 2.36 and above or later

View File

@ -14,7 +14,7 @@
This header file provides implementations for driver APIs for all modules selected in the GUI. This header file provides implementations for driver APIs for all modules selected in the GUI.
Generation Information : Generation Information :
Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8 Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8
Device : PIC18F26K83 Device : PIC18F25K83
Driver Version : 2.00 Driver Version : 2.00
The generated drivers are tested against the following: The generated drivers are tested against the following:
Compiler : XC8 2.36 and above or later Compiler : XC8 2.36 and above or later

View File

@ -14,7 +14,7 @@
This header file provides implementations for driver APIs for all modules selected in the GUI. This header file provides implementations for driver APIs for all modules selected in the GUI.
Generation Information : Generation Information :
Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8 Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8
Device : PIC18F26K83 Device : PIC18F25K83
Driver Version : 2.00 Driver Version : 2.00
The generated drivers are tested against the following: The generated drivers are tested against the following:
Compiler : XC8 2.36 and above or later Compiler : XC8 2.36 and above or later

View File

@ -14,7 +14,7 @@
This file provides implementations of driver APIs for MEMORY. This file provides implementations of driver APIs for MEMORY.
Generation Information : Generation Information :
Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8 Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8
Device : PIC18F26K83 Device : PIC18F25K83
Driver Version : 2.1.3 Driver Version : 2.1.3
The generated drivers are tested against the following: The generated drivers are tested against the following:
Compiler : XC8 2.36 and above Compiler : XC8 2.36 and above

View File

@ -14,7 +14,7 @@
This header file provides APIs for driver for MEMORY. This header file provides APIs for driver for MEMORY.
Generation Information : Generation Information :
Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8 Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8
Device : PIC18F26K83 Device : PIC18F25K83
Driver Version : 2.1.3 Driver Version : 2.1.3
The generated drivers are tested against the following: The generated drivers are tested against the following:
Compiler : XC8 2.36 and above Compiler : XC8 2.36 and above
@ -64,9 +64,9 @@
Section: Macro Declarations Section: Macro Declarations
*/ */
#define WRITE_FLASH_BLOCKSIZE 128 #define WRITE_FLASH_BLOCKSIZE 64
#define ERASE_FLASH_BLOCKSIZE 128 #define ERASE_FLASH_BLOCKSIZE 64
#define END_FLASH 0x010000 #define END_FLASH 0x008000
/** /**
Section: Flash Module APIs Section: Flash Module APIs

View File

@ -14,7 +14,7 @@
This header file provides implementations for pin APIs for all pins selected in the GUI. This header file provides implementations for pin APIs for all pins selected in the GUI.
Generation Information : Generation Information :
Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8 Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8
Device : PIC18F26K83 Device : PIC18F25K83
Driver Version : 2.11 Driver Version : 2.11
The generated drivers are tested against the following: The generated drivers are tested against the following:
Compiler : XC8 2.36 and above Compiler : XC8 2.36 and above

View File

@ -14,7 +14,7 @@
This header file provides APIs for driver for . This header file provides APIs for driver for .
Generation Information : Generation Information :
Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8 Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8
Device : PIC18F26K83 Device : PIC18F25K83
Driver Version : 2.11 Driver Version : 2.11
The generated drivers are tested against the following: The generated drivers are tested against the following:
Compiler : XC8 2.36 and above Compiler : XC8 2.36 and above

View File

@ -14,7 +14,7 @@
This source file provides APIs for TMR0. This source file provides APIs for TMR0.
Generation Information : Generation Information :
Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8 Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8
Device : PIC18F26K83 Device : PIC18F25K83
Driver Version : 3.10 Driver Version : 3.10
The generated drivers are tested against the following: The generated drivers are tested against the following:
Compiler : XC8 2.36 and above Compiler : XC8 2.36 and above

View File

@ -14,7 +14,7 @@
This header file provides APIs for TMR0. This header file provides APIs for TMR0.
Generation Information : Generation Information :
Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8 Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8
Device : PIC18F26K83 Device : PIC18F25K83
Driver Version : 3.10 Driver Version : 3.10
The generated drivers are tested against the following: The generated drivers are tested against the following:
Compiler : XC8 2.36 and above Compiler : XC8 2.36 and above

View File

@ -36,20 +36,20 @@ bool ALIVE_CHECKER_processEvent(Event* ev) {
break; break;
case STAC_SETUP: case STAC_SETUP:
if (ev->id = evACborn) { if (ev->id == evACborn) {
me->state = STAC_BORN; me->state = STAC_BORN;
} }
break; break;
case STAC_BORN: case STAC_BORN:
if (ev->id = evACready) { if (ev->id == evACready) {
me->state = STAC_WAIT; me->state = STAC_WAIT;
ALIVE_CHECKER_emitPoll(me, me->aliveTime*10, 0); ALIVE_CHECKER_emitPoll(me, me->aliveTime*10, 0);
} }
break; break;
case STAC_WAIT: case STAC_WAIT:
if (ev->id = evACpoll) { if (ev->id == evACpoll) {
if (me->isAlive) { if (me->isAlive) {
me->state = STAC_WAIT; me->state = STAC_WAIT;
ALIVE_CHECKER_emitPoll(me, me->aliveTime*10, 0); ALIVE_CHECKER_emitPoll(me, me->aliveTime*10, 0);
@ -60,7 +60,7 @@ bool ALIVE_CHECKER_processEvent(Event* ev) {
break; break;
case STAC_DEAD: case STAC_DEAD:
if(ev->id = evACborn) { if(ev->id == evACborn) {
me->state = STAC_BORN; me->state = STAC_BORN;
} }
break; break;

View File

@ -18,7 +18,7 @@ typedef enum {
} ALIVE_CHECKER_STATES; } ALIVE_CHECKER_STATES;
typedef enum { typedef enum {
evACinit = 100, // TODO change this number (< 256) evACinit = 15,
evACborn, evACborn,
evACready, evACready,
evACpoll evACpoll

View File

@ -6,6 +6,38 @@
*/ */
#include "can_interface.h" #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(){ void CAN_init(){
CAN_myself.receiveCan = NULL; CAN_myself.receiveCan = NULL;
@ -39,11 +71,13 @@ bool CAN_processEvent(Event* ev) {
if (me->receiveCan != NULL) { if (me->receiveCan != NULL) {
uint32_t canData = (uint32_t) data; uint32_t canData = (uint32_t) data;
data = data>>32; data = data>>32;
uint8_t idMsg = (uint8_t) data;
data = data>>4; CAN_4_BYTES tmpData;
uint8_t idRecipient = (uint8_t) data; tmpData.full.bytes = data;
data = data>>4; uint8_t idMsg = 0x0F && (tmpData.separate.byte0>>4);
uint8_t idSender = (uint8_t) data; uint8_t idRecipient = 0x0F && tmpData.separate.byte1;
uint8_t idSender = (tmpData.separate.byte1>>4);
me->receiveCan(idSender, idMsg, canData); 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.idType = 0; // I don't understand what is it
canMsg.frame.dlc = 4; // 4 bytes to send canMsg.frame.dlc = 4; // 4 bytes to send
canMsg.frame.rtr = 0; // no remote frame canMsg.frame.rtr = 0; // no remote frame
canMsg.frame.data0 = (uint8_t) data; canMsg.frame.data3 = (uint8_t) data;
data = data >> 8;
canMsg.frame.data1 = (uint8_t) data;
data = data >> 8; data = data >> 8;
canMsg.frame.data2 = (uint8_t) data; canMsg.frame.data2 = (uint8_t) data;
data = data >> 8; 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; data = data >> 8;
canMsg.frame.id = (uint32_t) data; canMsg.frame.id = (uint32_t) data;
CAN_transmit(&canMsg); CAN_transmit(&canMsg);
@ -107,14 +141,14 @@ void CAN_newMsg() {
uCAN_MSG canMsg; uCAN_MSG canMsg;
CAN_receive(&canMsg); CAN_receive(&canMsg);
data = canMsg.frame.id; data = canMsg.frame.id;
data = data<<32; data = data<<12;
data = canMsg.frame.data0; data = data | canMsg.frame.data0;
data = data<<8; data = data<<8;
data = canMsg.frame.data1; data = data | canMsg.frame.data1;
data = data<<8; data = data<<8;
data = canMsg.frame.data2; data = data | canMsg.frame.data2;
data = data<<8; data = data<<8;
data = canMsg.frame.data3; data = data | canMsg.frame.data3;
POST(&CAN_myself, &CAN_processEvent, evCAnewMsg, 0, data); 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; tmpData = (tmpData<<32) | data;
POST(&CAN_myself, &CAN_processEvent, evCAsend, 0, tmpData); POST(&CAN_myself, &CAN_processEvent, evCAsend, 0, tmpData);
} }
/***********
* SETTERS *
***********/
void CAN_setSender(uint8_t idSender) {
CAN_myself.sender = idSender;
}

View File

@ -15,7 +15,7 @@ typedef enum {
} CAN_STATES; } CAN_STATES;
typedef enum { typedef enum {
evCAinit = 10, // TODO change this number (< 256) evCAinit = 10,
evCAnewMsg, evCAnewMsg,
evCAsend evCAsend
} CAN_EVENTS; } CAN_EVENTS;

View File

@ -41,7 +41,6 @@
projectFiles="true"> projectFiles="true">
<logicalFolder name="app" displayName="app" projectFiles="true"> <logicalFolder name="app" displayName="app" projectFiles="true">
<itemPath>app/factory/factory.c</itemPath> <itemPath>app/factory/factory.c</itemPath>
<itemPath>app/main.c</itemPath>
</logicalFolder> </logicalFolder>
<logicalFolder name="board" displayName="board" projectFiles="true"> <logicalFolder name="board" displayName="board" projectFiles="true">
<itemPath>board/led/led.c</itemPath> <itemPath>board/led/led.c</itemPath>
@ -65,6 +64,7 @@
<itemPath>xf/event.c</itemPath> <itemPath>xf/event.c</itemPath>
<itemPath>xf/xf.c</itemPath> <itemPath>xf/xf.c</itemPath>
</logicalFolder> </logicalFolder>
<itemPath>main.c</itemPath>
</logicalFolder> </logicalFolder>
<logicalFolder name="ExternalFiles" <logicalFolder name="ExternalFiles"
displayName="Important Files" displayName="Important Files"
@ -75,19 +75,14 @@
</logicalFolder> </logicalFolder>
</logicalFolder> </logicalFolder>
<sourceRootList> <sourceRootList>
<Elem>board</Elem> <Elem>.</Elem>
<Elem>led</Elem>
<Elem>factory</Elem>
<Elem>middleware</Elem>
<Elem>app</Elem>
<Elem>xf</Elem>
</sourceRootList> </sourceRootList>
<projectmakefile>Makefile</projectmakefile> <projectmakefile>Makefile</projectmakefile>
<confs> <confs>
<conf name="default" type="2"> <conf name="default" type="2">
<toolsSet> <toolsSet>
<developmentServer>localhost</developmentServer> <developmentServer>localhost</developmentServer>
<targetDevice>PIC18F26K83</targetDevice> <targetDevice>PIC18F25K83</targetDevice>
<targetHeader></targetHeader> <targetHeader></targetHeader>
<targetPluginBoard></targetPluginBoard> <targetPluginBoard></targetPluginBoard>
<platformTool>PICkit3PlatformTool</platformTool> <platformTool>PICkit3PlatformTool</platformTool>
@ -245,7 +240,7 @@
<property key="programoptions.programcalmem" value="false"/> <property key="programoptions.programcalmem" value="false"/>
<property key="programoptions.programuserotp" value="false"/> <property key="programoptions.programuserotp" value="false"/>
<property key="programoptions.testmodeentrymethod" value="VDDFirst"/> <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="programoptions.uselvpprogramming" value="false"/>
<property key="voltagevalue" value="5.0"/> <property key="voltagevalue" value="5.0"/>
</PICkit3PlatformTool> </PICkit3PlatformTool>
@ -290,7 +285,7 @@
<property key="programoptions.programcalmem" value="false"/> <property key="programoptions.programcalmem" value="false"/>
<property key="programoptions.programuserotp" value="false"/> <property key="programoptions.programuserotp" value="false"/>
<property key="programoptions.testmodeentrymethod" value="VDDFirst"/> <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="programoptions.uselvpprogramming" value="false"/>
<property key="voltagevalue" value="5.0"/> <property key="voltagevalue" value="5.0"/>
</Tool> </Tool>

View File

@ -13,12 +13,7 @@
<sourceEncoding>ISO-8859-1</sourceEncoding> <sourceEncoding>ISO-8859-1</sourceEncoding>
<make-dep-projects/> <make-dep-projects/>
<sourceRootList> <sourceRootList>
<sourceRootElem>board</sourceRootElem> <sourceRootElem>.</sourceRootElem>
<sourceRootElem>led</sourceRootElem>
<sourceRootElem>factory</sourceRootElem>
<sourceRootElem>middleware</sourceRootElem>
<sourceRootElem>app</sourceRootElem>
<sourceRootElem>xf</sourceRootElem>
</sourceRootList> </sourceRootList>
<confList> <confList>
<confElem> <confElem>

File diff suppressed because one or more lines are too long