From 7b4fb451c75f6a5a0e78a946fc72fec8be5f8559 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Heredero?= Date: Fri, 25 Aug 2023 09:43:03 +0200 Subject: [PATCH 1/7] add watchdog --- UML/watchdog.uxf | 74 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 UML/watchdog.uxf diff --git a/UML/watchdog.uxf b/UML/watchdog.uxf new file mode 100644 index 0000000..be47bc3 --- /dev/null +++ b/UML/watchdog.uxf @@ -0,0 +1,74 @@ + + + 15 + + UMLSpecialState + + 660 + 225 + 30 + 30 + + type=initial + + + + Relation + + 660 + 240 + 120 + 105 + + lt=-> +evWDinit + 10.0;10.0;10.0;50.0 + + + UMLState + + 600 + 315 + 150 + 60 + + STWD_ALIVE + + + + Relation + + 525 + 330 + 270 + 135 + + lt=-> +m1=evWDpoll + 100.0;30.0;100.0;70.0;10.0;70.0;10.0;10.0;50.0;10.0 + + + UMLNote + + 825 + 315 + 150 + 60 + + send alive +by CAN + + + + UMLNote + + 720 + 180 + 150 + 60 + + read time on +EPROM + + + From d6d667a3c4a23aca69bfdc98c717d048b92d07b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Heredero?= Date: Fri, 25 Aug 2023 11:17:53 +0200 Subject: [PATCH 2/7] fix watchdog --- .../nbproject/configurations.xml | 5 +- 306-controller_interface.X/ss22ep.mc3 | 88 +++++++++---------- UML/watchdog.uxf | 24 ++--- 3 files changed, 58 insertions(+), 59 deletions(-) diff --git a/306-controller_interface.X/nbproject/configurations.xml b/306-controller_interface.X/nbproject/configurations.xml index bb81313..11b024b 100644 --- a/306-controller_interface.X/nbproject/configurations.xml +++ b/306-controller_interface.X/nbproject/configurations.xml @@ -210,7 +210,6 @@ - @@ -241,7 +240,7 @@ - + @@ -286,7 +285,7 @@ - + diff --git a/306-controller_interface.X/ss22ep.mc3 b/306-controller_interface.X/ss22ep.mc3 index 24dfd8f..6fedf69 100644 --- a/306-controller_interface.X/ss22ep.mc3 +++ b/306-controller_interface.X/ss22ep.mc3 @@ -1948,7 +1948,7 @@ - {"dataArray":[{"DMA Channels":{"data":{"isDisable":"true","options":"--NONE--","text":"DMA CHANNEL1","value":"false"},"id":"DMA Channels_rowCount_0"},"Src Module":{"data":{"isDisable":"true","options":"--NONE--,ECAN,MEMORY,TMR0","text":"--NONE--","value":"--NONE--"},"id":"Src Module_rowCount_0"},"Src Region":{"data":{"isDisable":"true","options":"SFR#disabled,GPR#enabled,Program Flash#enabled,Data EEPROM#enabled","text":"GPR","value":"GPR"},"id":"Src Region_rowCount_0"},"Src SFR":{"Src SFR":{"isDisable":"true","options":"","text":"","value":""},"data":{"isDisable":"true","options":"","text":"","value":""},"id":"Src SFR_rowCount_0"},"Src VarName":{"data":{"isDisable":"true","options":"","text":"SrcVarName0","value":"SrcVarName0"},"Src VarName":{"isDisable":"true","options":"","text":"SrcVarName0","value":"SrcVarName0"},"id":"Src VarName_rowCount_0"},"Src VarSize":{"data":{"isDisable":"true","options":"","text":"10","value":"10"},"id":"Src VarSize_rowCount_0","Src VarSize":{"isDisable":"true","options":"","text":"10","value":"10"}},"Src Address":{"data":{"isDisable":"true","options":"","text":"Enter Address0","value":"Enter Address0"},"id":"Src Address_rowCount_0","Src Address":{"isDisable":"true","options":"","text":"Enter Address0","value":"Enter Address0"}},"Src Mode":{"Src Mode":{"isDisable":"true","options":"decremented,incremented,unchanged","text":"unchanged","value":"unchanged"},"data":{"isDisable":"true","options":"decremented,incremented,unchanged","text":"unchanged","value":"unchanged"},"id":"Src Mode_rowCount_0"},"Src Message Size":{"data":{"isDisable":"true","options":"","text":"1","value":"1"},"Src Message Size":{"isDisable":"true","options":"","text":"1","value":"1"},"id":"Src Message Size_rowCount_0"},"Dst Module":{"data":{"isDisable":"true","options":"--NONE--,ECAN,MEMORY,TMR0","text":"--NONE--","value":"--NONE--"},"id":"Dst Module_rowCount_0"},"Dst Region":{"data":{"isDisable":"true","options":"SFR,GPR","text":"GPR","value":"GPR"},"id":"Dst Region_rowCount_0"},"Dst SFR":{"Dst SFR":{"isDisable":"true","options":"","text":"","value":""},"data":{"isDisable":"true","options":"","text":"","value":""},"id":"Dst SFR_rowCount_0"},"Dst VarName":{"data":{"isDisable":"true","options":"","text":"DstVarName0","value":"DstVarName0"},"Dst VarName":{"isDisable":"true","options":"","text":"DstVarName0","value":"DstVarName0"},"id":"Dst VarName_rowCount_0"},"Dst VarSize":{"data":{"isDisable":"true","options":"","text":"10","value":"10"},"id":"Dst VarSize_rowCount_0","Dst VarSize":{"isDisable":"true","options":"","text":"10","value":"10"}},"Dst Mode":{"data":{"isDisable":"true","options":"decremented,incremented,unchanged","text":"unchanged","value":"unchanged"},"Dst Mode":{"isDisable":"true","options":"decremented,incremented,unchanged","text":"unchanged","value":"unchanged"},"id":"Dst Mode_rowCount_0"},"Dst Message Size":{"data":{"isDisable":"true","options":"","text":"1","value":"1"},"Dst Message Size":{"isDisable":"true","options":"","text":"1","value":"1"},"id":"Dst Message Size_rowCount_0"},"Start Trigger":{"Start Trigger":{"isDisable":"true","options":"AD,ADT,CAN_ERRIF,CAN_IRXIF,CAN_RXB0IF\/FIFOIF,CAN_RXB1IF\/RXBnIF,CAN_TXB0IF,CAN_TXB1IF,CAN_TXB2IF\/TXBnIF,CAN_WAKIF,CCP1,CCP2,CCP3,CCP4,CLC1,CLC2,CLC3,CLC4,CMP1,CMP2,CRC,CSW,CWG1,CWG2,CWG3,DMA1A,DMA1DCNT,DMA1OR,DMA1SCNT,DMA2A,DMA2DCNT,DMA2OR,DMA2SCNT,I2C1,I2C1E,I2C1RX,I2C1TX,I2C2,I2C2E,I2C2RX,I2C2TX,INT0,INT1,INT2,IOC,LVD,NCO,NVM,None,OSF,SCAN,SMT1,SMT1PRA,SMT1PWA,SMT2,SMT2PRA,SMT2PWA,SPI1,SPI1RX,SPI1TX,TMR0,TMR1,TMR1G,TMR2,TMR3,TMR3G,TMR4,TMR5,TMR5G,TMR6,U1,U1E,U1RX,U1TX,U2,U2E,U2RX,U2TX,ZCD","text":"None","value":"None"},"data":{"isDisable":"true","options":"AD,ADT,CAN_ERRIF,CAN_IRXIF,CAN_RXB0IF\/FIFOIF,CAN_RXB1IF\/RXBnIF,CAN_TXB0IF,CAN_TXB1IF,CAN_TXB2IF\/TXBnIF,CAN_WAKIF,CCP1,CCP2,CCP3,CCP4,CLC1,CLC2,CLC3,CLC4,CMP1,CMP2,CRC,CSW,CWG1,CWG2,CWG3,DMA1A,DMA1DCNT,DMA1OR,DMA1SCNT,DMA2A,DMA2DCNT,DMA2OR,DMA2SCNT,I2C1,I2C1E,I2C1RX,I2C1TX,I2C2,I2C2E,I2C2RX,I2C2TX,INT0,INT1,INT2,IOC,LVD,NCO,NVM,None,OSF,SCAN,SMT1,SMT1PRA,SMT1PWA,SMT2,SMT2PRA,SMT2PWA,SPI1,SPI1RX,SPI1TX,TMR0,TMR1,TMR1G,TMR2,TMR3,TMR3G,TMR4,TMR5,TMR5G,TMR6,U1,U1E,U1RX,U1TX,U2,U2E,U2RX,U2TX,ZCD","text":"None","value":"None"},"id":"Start Trigger_rowCount_0"},"Abort Trigger":{"data":{"isDisable":"true","options":"AD,ADT,CAN_ERRIF,CAN_IRXIF,CAN_RXB0IF\/FIFOIF,CAN_RXB1IF\/RXBnIF,CAN_TXB0IF,CAN_TXB1IF,CAN_TXB2IF\/TXBnIF,CAN_WAKIF,CCP1,CCP2,CCP3,CCP4,CLC1,CLC2,CLC3,CLC4,CMP1,CMP2,CRC,CSW,CWG1,CWG2,CWG3,DMA1A,DMA1DCNT,DMA1OR,DMA1SCNT,DMA2A,DMA2DCNT,DMA2OR,DMA2SCNT,I2C1,I2C1E,I2C1RX,I2C1TX,I2C2,I2C2E,I2C2RX,I2C2TX,INT0,INT1,INT2,IOC,LVD,NCO,NVM,None,OSF,SCAN,SMT1,SMT1PRA,SMT1PWA,SMT2,SMT2PRA,SMT2PWA,SPI1,SPI1RX,SPI1TX,TMR0,TMR1,TMR1G,TMR2,TMR3,TMR3G,TMR4,TMR5,TMR5G,TMR6,U1,U1E,U1RX,U1TX,U2,U2E,U2RX,U2TX,ZCD","text":"None","value":"None"},"id":"Abort Trigger_rowCount_0","Abort Trigger":{"isDisable":"true","options":"AD,ADT,CAN_ERRIF,CAN_IRXIF,CAN_RXB0IF\/FIFOIF,CAN_RXB1IF\/RXBnIF,CAN_TXB0IF,CAN_TXB1IF,CAN_TXB2IF\/TXBnIF,CAN_WAKIF,CCP1,CCP2,CCP3,CCP4,CLC1,CLC2,CLC3,CLC4,CMP1,CMP2,CRC,CSW,CWG1,CWG2,CWG3,DMA1A,DMA1DCNT,DMA1OR,DMA1SCNT,DMA2A,DMA2DCNT,DMA2OR,DMA2SCNT,I2C1,I2C1E,I2C1RX,I2C1TX,I2C2,I2C2E,I2C2RX,I2C2TX,INT0,INT1,INT2,IOC,LVD,NCO,NVM,None,OSF,SCAN,SMT1,SMT1PRA,SMT1PWA,SMT2,SMT2PRA,SMT2PWA,SPI1,SPI1RX,SPI1TX,TMR0,TMR1,TMR1G,TMR2,TMR3,TMR3G,TMR4,TMR5,TMR5G,TMR6,U1,U1E,U1RX,U1TX,U2,U2E,U2RX,U2TX,ZCD","text":"None","value":"None"}}},{"DMA Channels":{"data":{"isDisable":"true","options":"--NONE--","text":"DMA CHANNEL2","value":"false"},"id":"DMA Channels_rowCount_1"},"Src Module":{"data":{"isDisable":"true","options":"--NONE--,ECAN,MEMORY,TMR0","text":"--NONE--","value":"--NONE--"},"id":"Src Module_rowCount_1"},"Src Region":{"data":{"isDisable":"true","options":"SFR#disabled,GPR#enabled,Program Flash#enabled,Data EEPROM#enabled","text":"GPR","value":"GPR"},"id":"Src Region_rowCount_1"},"Src SFR":{"Src SFR":{"isDisable":"true","options":"","text":"","value":""},"data":{"isDisable":"true","options":"","text":"","value":""},"id":"Src SFR_rowCount_1"},"Src VarName":{"data":{"isDisable":"true","options":"","text":"SrcVarName1","value":"SrcVarName1"},"Src VarName":{"isDisable":"true","options":"","text":"SrcVarName1","value":"SrcVarName1"},"id":"Src VarName_rowCount_1"},"Src VarSize":{"data":{"isDisable":"true","options":"","text":"10","value":"10"},"id":"Src VarSize_rowCount_1","Src VarSize":{"isDisable":"true","options":"","text":"10","value":"10"}},"Src Address":{"data":{"isDisable":"true","options":"","text":"Enter Address1","value":"Enter Address1"},"id":"Src Address_rowCount_1","Src Address":{"isDisable":"true","options":"","text":"Enter Address1","value":"Enter Address1"}},"Src Mode":{"Src Mode":{"isDisable":"true","options":"decremented,incremented,unchanged","text":"unchanged","value":"unchanged"},"data":{"isDisable":"true","options":"decremented,incremented,unchanged","text":"unchanged","value":"unchanged"},"id":"Src Mode_rowCount_1"},"Src Message Size":{"data":{"isDisable":"true","options":"","text":"1","value":"1"},"Src Message Size":{"isDisable":"true","options":"","text":"1","value":"1"},"id":"Src Message Size_rowCount_1"},"Dst Module":{"data":{"isDisable":"true","options":"--NONE--,ECAN,MEMORY,TMR0","text":"--NONE--","value":"--NONE--"},"id":"Dst Module_rowCount_1"},"Dst Region":{"data":{"isDisable":"true","options":"SFR,GPR","text":"GPR","value":"GPR"},"id":"Dst Region_rowCount_1"},"Dst SFR":{"Dst SFR":{"isDisable":"true","options":"","text":"","value":""},"data":{"isDisable":"true","options":"","text":"","value":""},"id":"Dst SFR_rowCount_1"},"Dst VarName":{"data":{"isDisable":"true","options":"","text":"DstVarName1","value":"DstVarName1"},"Dst VarName":{"isDisable":"true","options":"","text":"DstVarName1","value":"DstVarName1"},"id":"Dst VarName_rowCount_1"},"Dst VarSize":{"data":{"isDisable":"true","options":"","text":"10","value":"10"},"id":"Dst VarSize_rowCount_1","Dst VarSize":{"isDisable":"true","options":"","text":"10","value":"10"}},"Dst Mode":{"data":{"isDisable":"true","options":"decremented,incremented,unchanged","text":"unchanged","value":"unchanged"},"Dst Mode":{"isDisable":"true","options":"decremented,incremented,unchanged","text":"unchanged","value":"unchanged"},"id":"Dst Mode_rowCount_1"},"Dst Message Size":{"data":{"isDisable":"true","options":"","text":"1","value":"1"},"Dst Message Size":{"isDisable":"true","options":"","text":"1","value":"1"},"id":"Dst Message Size_rowCount_1"},"Start Trigger":{"Start Trigger":{"isDisable":"true","options":"AD,ADT,CAN_ERRIF,CAN_IRXIF,CAN_RXB0IF\/FIFOIF,CAN_RXB1IF\/RXBnIF,CAN_TXB0IF,CAN_TXB1IF,CAN_TXB2IF\/TXBnIF,CAN_WAKIF,CCP1,CCP2,CCP3,CCP4,CLC1,CLC2,CLC3,CLC4,CMP1,CMP2,CRC,CSW,CWG1,CWG2,CWG3,DMA1A,DMA1DCNT,DMA1OR,DMA1SCNT,DMA2A,DMA2DCNT,DMA2OR,DMA2SCNT,I2C1,I2C1E,I2C1RX,I2C1TX,I2C2,I2C2E,I2C2RX,I2C2TX,INT0,INT1,INT2,IOC,LVD,NCO,NVM,None,OSF,SCAN,SMT1,SMT1PRA,SMT1PWA,SMT2,SMT2PRA,SMT2PWA,SPI1,SPI1RX,SPI1TX,TMR0,TMR1,TMR1G,TMR2,TMR3,TMR3G,TMR4,TMR5,TMR5G,TMR6,U1,U1E,U1RX,U1TX,U2,U2E,U2RX,U2TX,ZCD","text":"None","value":"None"},"data":{"isDisable":"true","options":"AD,ADT,CAN_ERRIF,CAN_IRXIF,CAN_RXB0IF\/FIFOIF,CAN_RXB1IF\/RXBnIF,CAN_TXB0IF,CAN_TXB1IF,CAN_TXB2IF\/TXBnIF,CAN_WAKIF,CCP1,CCP2,CCP3,CCP4,CLC1,CLC2,CLC3,CLC4,CMP1,CMP2,CRC,CSW,CWG1,CWG2,CWG3,DMA1A,DMA1DCNT,DMA1OR,DMA1SCNT,DMA2A,DMA2DCNT,DMA2OR,DMA2SCNT,I2C1,I2C1E,I2C1RX,I2C1TX,I2C2,I2C2E,I2C2RX,I2C2TX,INT0,INT1,INT2,IOC,LVD,NCO,NVM,None,OSF,SCAN,SMT1,SMT1PRA,SMT1PWA,SMT2,SMT2PRA,SMT2PWA,SPI1,SPI1RX,SPI1TX,TMR0,TMR1,TMR1G,TMR2,TMR3,TMR3G,TMR4,TMR5,TMR5G,TMR6,U1,U1E,U1RX,U1TX,U2,U2E,U2RX,U2TX,ZCD","text":"None","value":"None"},"id":"Start Trigger_rowCount_1"},"Abort Trigger":{"data":{"isDisable":"true","options":"AD,ADT,CAN_ERRIF,CAN_IRXIF,CAN_RXB0IF\/FIFOIF,CAN_RXB1IF\/RXBnIF,CAN_TXB0IF,CAN_TXB1IF,CAN_TXB2IF\/TXBnIF,CAN_WAKIF,CCP1,CCP2,CCP3,CCP4,CLC1,CLC2,CLC3,CLC4,CMP1,CMP2,CRC,CSW,CWG1,CWG2,CWG3,DMA1A,DMA1DCNT,DMA1OR,DMA1SCNT,DMA2A,DMA2DCNT,DMA2OR,DMA2SCNT,I2C1,I2C1E,I2C1RX,I2C1TX,I2C2,I2C2E,I2C2RX,I2C2TX,INT0,INT1,INT2,IOC,LVD,NCO,NVM,None,OSF,SCAN,SMT1,SMT1PRA,SMT1PWA,SMT2,SMT2PRA,SMT2PWA,SPI1,SPI1RX,SPI1TX,TMR0,TMR1,TMR1G,TMR2,TMR3,TMR3G,TMR4,TMR5,TMR5G,TMR6,U1,U1E,U1RX,U1TX,U2,U2E,U2RX,U2TX,ZCD","text":"None","value":"None"},"id":"Abort Trigger_rowCount_1","Abort Trigger":{"isDisable":"true","options":"AD,ADT,CAN_ERRIF,CAN_IRXIF,CAN_RXB0IF\/FIFOIF,CAN_RXB1IF\/RXBnIF,CAN_TXB0IF,CAN_TXB1IF,CAN_TXB2IF\/TXBnIF,CAN_WAKIF,CCP1,CCP2,CCP3,CCP4,CLC1,CLC2,CLC3,CLC4,CMP1,CMP2,CRC,CSW,CWG1,CWG2,CWG3,DMA1A,DMA1DCNT,DMA1OR,DMA1SCNT,DMA2A,DMA2DCNT,DMA2OR,DMA2SCNT,I2C1,I2C1E,I2C1RX,I2C1TX,I2C2,I2C2E,I2C2RX,I2C2TX,INT0,INT1,INT2,IOC,LVD,NCO,NVM,None,OSF,SCAN,SMT1,SMT1PRA,SMT1PWA,SMT2,SMT2PRA,SMT2PWA,SPI1,SPI1RX,SPI1TX,TMR0,TMR1,TMR1G,TMR2,TMR3,TMR3G,TMR4,TMR5,TMR5G,TMR6,U1,U1E,U1RX,U1TX,U2,U2E,U2RX,U2TX,ZCD","text":"None","value":"None"}}}],"type":"tableDynamicControls","key":"dmaTable"} + {"dataArray":[{"DMA Channels":{"data":{"isDisable":"true","options":"--NONE--","text":"DMA CHANNEL1","value":"false"},"id":"DMA Channels_rowCount_0"},"Src Module":{"data":{"isDisable":"true","options":"--NONE--,TMR0,ECAN,MEMORY","text":"--NONE--","value":"--NONE--"},"id":"Src Module_rowCount_0"},"Src Region":{"data":{"isDisable":"true","options":"SFR#disabled,GPR#enabled,Program Flash#enabled,Data EEPROM#enabled","text":"GPR","value":"GPR"},"id":"Src Region_rowCount_0"},"Src SFR":{"Src SFR":{"isDisable":"true","options":"","text":"","value":""},"data":{"isDisable":"true","options":"","text":"","value":""},"id":"Src SFR_rowCount_0"},"Src VarName":{"data":{"isDisable":"true","options":"","text":"SrcVarName0","value":"SrcVarName0"},"Src VarName":{"isDisable":"true","options":"","text":"SrcVarName0","value":"SrcVarName0"},"id":"Src VarName_rowCount_0"},"Src VarSize":{"data":{"isDisable":"true","options":"","text":"10","value":"10"},"id":"Src VarSize_rowCount_0","Src VarSize":{"isDisable":"true","options":"","text":"10","value":"10"}},"Src Address":{"data":{"isDisable":"true","options":"","text":"Enter Address0","value":"Enter Address0"},"id":"Src Address_rowCount_0","Src Address":{"isDisable":"true","options":"","text":"Enter Address0","value":"Enter Address0"}},"Src Mode":{"Src Mode":{"isDisable":"true","options":"decremented,incremented,unchanged","text":"unchanged","value":"unchanged"},"data":{"isDisable":"true","options":"decremented,incremented,unchanged","text":"unchanged","value":"unchanged"},"id":"Src Mode_rowCount_0"},"Src Message Size":{"data":{"isDisable":"true","options":"","text":"1","value":"1"},"Src Message Size":{"isDisable":"true","options":"","text":"1","value":"1"},"id":"Src Message Size_rowCount_0"},"Dst Module":{"data":{"isDisable":"true","options":"--NONE--,TMR0,ECAN,MEMORY","text":"--NONE--","value":"--NONE--"},"id":"Dst Module_rowCount_0"},"Dst Region":{"data":{"isDisable":"true","options":"SFR,GPR","text":"GPR","value":"GPR"},"id":"Dst Region_rowCount_0"},"Dst SFR":{"Dst SFR":{"isDisable":"true","options":"","text":"","value":""},"data":{"isDisable":"true","options":"","text":"","value":""},"id":"Dst SFR_rowCount_0"},"Dst VarName":{"data":{"isDisable":"true","options":"","text":"DstVarName0","value":"DstVarName0"},"Dst VarName":{"isDisable":"true","options":"","text":"DstVarName0","value":"DstVarName0"},"id":"Dst VarName_rowCount_0"},"Dst VarSize":{"data":{"isDisable":"true","options":"","text":"10","value":"10"},"id":"Dst VarSize_rowCount_0","Dst VarSize":{"isDisable":"true","options":"","text":"10","value":"10"}},"Dst Mode":{"data":{"isDisable":"true","options":"decremented,incremented,unchanged","text":"unchanged","value":"unchanged"},"Dst Mode":{"isDisable":"true","options":"decremented,incremented,unchanged","text":"unchanged","value":"unchanged"},"id":"Dst Mode_rowCount_0"},"Dst Message Size":{"data":{"isDisable":"true","options":"","text":"1","value":"1"},"Dst Message Size":{"isDisable":"true","options":"","text":"1","value":"1"},"id":"Dst Message Size_rowCount_0"},"Start Trigger":{"Start Trigger":{"isDisable":"true","options":"AD,ADT,CAN_ERRIF,CAN_IRXIF,CAN_RXB0IF\/FIFOIF,CAN_RXB1IF\/RXBnIF,CAN_TXB0IF,CAN_TXB1IF,CAN_TXB2IF\/TXBnIF,CAN_WAKIF,CCP1,CCP2,CCP3,CCP4,CLC1,CLC2,CLC3,CLC4,CMP1,CMP2,CRC,CSW,CWG1,CWG2,CWG3,DMA1A,DMA1DCNT,DMA1OR,DMA1SCNT,DMA2A,DMA2DCNT,DMA2OR,DMA2SCNT,I2C1,I2C1E,I2C1RX,I2C1TX,I2C2,I2C2E,I2C2RX,I2C2TX,INT0,INT1,INT2,IOC,LVD,NCO,NVM,None,OSF,SCAN,SMT1,SMT1PRA,SMT1PWA,SMT2,SMT2PRA,SMT2PWA,SPI1,SPI1RX,SPI1TX,TMR0,TMR1,TMR1G,TMR2,TMR3,TMR3G,TMR4,TMR5,TMR5G,TMR6,U1,U1E,U1RX,U1TX,U2,U2E,U2RX,U2TX,ZCD","text":"None","value":"None"},"data":{"isDisable":"true","options":"AD,ADT,CAN_ERRIF,CAN_IRXIF,CAN_RXB0IF\/FIFOIF,CAN_RXB1IF\/RXBnIF,CAN_TXB0IF,CAN_TXB1IF,CAN_TXB2IF\/TXBnIF,CAN_WAKIF,CCP1,CCP2,CCP3,CCP4,CLC1,CLC2,CLC3,CLC4,CMP1,CMP2,CRC,CSW,CWG1,CWG2,CWG3,DMA1A,DMA1DCNT,DMA1OR,DMA1SCNT,DMA2A,DMA2DCNT,DMA2OR,DMA2SCNT,I2C1,I2C1E,I2C1RX,I2C1TX,I2C2,I2C2E,I2C2RX,I2C2TX,INT0,INT1,INT2,IOC,LVD,NCO,NVM,None,OSF,SCAN,SMT1,SMT1PRA,SMT1PWA,SMT2,SMT2PRA,SMT2PWA,SPI1,SPI1RX,SPI1TX,TMR0,TMR1,TMR1G,TMR2,TMR3,TMR3G,TMR4,TMR5,TMR5G,TMR6,U1,U1E,U1RX,U1TX,U2,U2E,U2RX,U2TX,ZCD","text":"None","value":"None"},"id":"Start Trigger_rowCount_0"},"Abort Trigger":{"data":{"isDisable":"true","options":"AD,ADT,CAN_ERRIF,CAN_IRXIF,CAN_RXB0IF\/FIFOIF,CAN_RXB1IF\/RXBnIF,CAN_TXB0IF,CAN_TXB1IF,CAN_TXB2IF\/TXBnIF,CAN_WAKIF,CCP1,CCP2,CCP3,CCP4,CLC1,CLC2,CLC3,CLC4,CMP1,CMP2,CRC,CSW,CWG1,CWG2,CWG3,DMA1A,DMA1DCNT,DMA1OR,DMA1SCNT,DMA2A,DMA2DCNT,DMA2OR,DMA2SCNT,I2C1,I2C1E,I2C1RX,I2C1TX,I2C2,I2C2E,I2C2RX,I2C2TX,INT0,INT1,INT2,IOC,LVD,NCO,NVM,None,OSF,SCAN,SMT1,SMT1PRA,SMT1PWA,SMT2,SMT2PRA,SMT2PWA,SPI1,SPI1RX,SPI1TX,TMR0,TMR1,TMR1G,TMR2,TMR3,TMR3G,TMR4,TMR5,TMR5G,TMR6,U1,U1E,U1RX,U1TX,U2,U2E,U2RX,U2TX,ZCD","text":"None","value":"None"},"id":"Abort Trigger_rowCount_0","Abort Trigger":{"isDisable":"true","options":"AD,ADT,CAN_ERRIF,CAN_IRXIF,CAN_RXB0IF\/FIFOIF,CAN_RXB1IF\/RXBnIF,CAN_TXB0IF,CAN_TXB1IF,CAN_TXB2IF\/TXBnIF,CAN_WAKIF,CCP1,CCP2,CCP3,CCP4,CLC1,CLC2,CLC3,CLC4,CMP1,CMP2,CRC,CSW,CWG1,CWG2,CWG3,DMA1A,DMA1DCNT,DMA1OR,DMA1SCNT,DMA2A,DMA2DCNT,DMA2OR,DMA2SCNT,I2C1,I2C1E,I2C1RX,I2C1TX,I2C2,I2C2E,I2C2RX,I2C2TX,INT0,INT1,INT2,IOC,LVD,NCO,NVM,None,OSF,SCAN,SMT1,SMT1PRA,SMT1PWA,SMT2,SMT2PRA,SMT2PWA,SPI1,SPI1RX,SPI1TX,TMR0,TMR1,TMR1G,TMR2,TMR3,TMR3G,TMR4,TMR5,TMR5G,TMR6,U1,U1E,U1RX,U1TX,U2,U2E,U2RX,U2TX,ZCD","text":"None","value":"None"}}},{"DMA Channels":{"data":{"isDisable":"true","options":"--NONE--","text":"DMA CHANNEL2","value":"false"},"id":"DMA Channels_rowCount_1"},"Src Module":{"data":{"isDisable":"true","options":"--NONE--,TMR0,ECAN,MEMORY","text":"--NONE--","value":"--NONE--"},"id":"Src Module_rowCount_1"},"Src Region":{"data":{"isDisable":"true","options":"SFR#disabled,GPR#enabled,Program Flash#enabled,Data EEPROM#enabled","text":"GPR","value":"GPR"},"id":"Src Region_rowCount_1"},"Src SFR":{"Src SFR":{"isDisable":"true","options":"","text":"","value":""},"data":{"isDisable":"true","options":"","text":"","value":""},"id":"Src SFR_rowCount_1"},"Src VarName":{"data":{"isDisable":"true","options":"","text":"SrcVarName1","value":"SrcVarName1"},"Src VarName":{"isDisable":"true","options":"","text":"SrcVarName1","value":"SrcVarName1"},"id":"Src VarName_rowCount_1"},"Src VarSize":{"data":{"isDisable":"true","options":"","text":"10","value":"10"},"id":"Src VarSize_rowCount_1","Src VarSize":{"isDisable":"true","options":"","text":"10","value":"10"}},"Src Address":{"data":{"isDisable":"true","options":"","text":"Enter Address1","value":"Enter Address1"},"id":"Src Address_rowCount_1","Src Address":{"isDisable":"true","options":"","text":"Enter Address1","value":"Enter Address1"}},"Src Mode":{"Src Mode":{"isDisable":"true","options":"decremented,incremented,unchanged","text":"unchanged","value":"unchanged"},"data":{"isDisable":"true","options":"decremented,incremented,unchanged","text":"unchanged","value":"unchanged"},"id":"Src Mode_rowCount_1"},"Src Message Size":{"data":{"isDisable":"true","options":"","text":"1","value":"1"},"Src Message Size":{"isDisable":"true","options":"","text":"1","value":"1"},"id":"Src Message Size_rowCount_1"},"Dst Module":{"data":{"isDisable":"true","options":"--NONE--,TMR0,ECAN,MEMORY","text":"--NONE--","value":"--NONE--"},"id":"Dst Module_rowCount_1"},"Dst Region":{"data":{"isDisable":"true","options":"SFR,GPR","text":"GPR","value":"GPR"},"id":"Dst Region_rowCount_1"},"Dst SFR":{"Dst SFR":{"isDisable":"true","options":"","text":"","value":""},"data":{"isDisable":"true","options":"","text":"","value":""},"id":"Dst SFR_rowCount_1"},"Dst VarName":{"data":{"isDisable":"true","options":"","text":"DstVarName1","value":"DstVarName1"},"Dst VarName":{"isDisable":"true","options":"","text":"DstVarName1","value":"DstVarName1"},"id":"Dst VarName_rowCount_1"},"Dst VarSize":{"data":{"isDisable":"true","options":"","text":"10","value":"10"},"id":"Dst VarSize_rowCount_1","Dst VarSize":{"isDisable":"true","options":"","text":"10","value":"10"}},"Dst Mode":{"data":{"isDisable":"true","options":"decremented,incremented,unchanged","text":"unchanged","value":"unchanged"},"Dst Mode":{"isDisable":"true","options":"decremented,incremented,unchanged","text":"unchanged","value":"unchanged"},"id":"Dst Mode_rowCount_1"},"Dst Message Size":{"data":{"isDisable":"true","options":"","text":"1","value":"1"},"Dst Message Size":{"isDisable":"true","options":"","text":"1","value":"1"},"id":"Dst Message Size_rowCount_1"},"Start Trigger":{"Start Trigger":{"isDisable":"true","options":"AD,ADT,CAN_ERRIF,CAN_IRXIF,CAN_RXB0IF\/FIFOIF,CAN_RXB1IF\/RXBnIF,CAN_TXB0IF,CAN_TXB1IF,CAN_TXB2IF\/TXBnIF,CAN_WAKIF,CCP1,CCP2,CCP3,CCP4,CLC1,CLC2,CLC3,CLC4,CMP1,CMP2,CRC,CSW,CWG1,CWG2,CWG3,DMA1A,DMA1DCNT,DMA1OR,DMA1SCNT,DMA2A,DMA2DCNT,DMA2OR,DMA2SCNT,I2C1,I2C1E,I2C1RX,I2C1TX,I2C2,I2C2E,I2C2RX,I2C2TX,INT0,INT1,INT2,IOC,LVD,NCO,NVM,None,OSF,SCAN,SMT1,SMT1PRA,SMT1PWA,SMT2,SMT2PRA,SMT2PWA,SPI1,SPI1RX,SPI1TX,TMR0,TMR1,TMR1G,TMR2,TMR3,TMR3G,TMR4,TMR5,TMR5G,TMR6,U1,U1E,U1RX,U1TX,U2,U2E,U2RX,U2TX,ZCD","text":"None","value":"None"},"data":{"isDisable":"true","options":"AD,ADT,CAN_ERRIF,CAN_IRXIF,CAN_RXB0IF\/FIFOIF,CAN_RXB1IF\/RXBnIF,CAN_TXB0IF,CAN_TXB1IF,CAN_TXB2IF\/TXBnIF,CAN_WAKIF,CCP1,CCP2,CCP3,CCP4,CLC1,CLC2,CLC3,CLC4,CMP1,CMP2,CRC,CSW,CWG1,CWG2,CWG3,DMA1A,DMA1DCNT,DMA1OR,DMA1SCNT,DMA2A,DMA2DCNT,DMA2OR,DMA2SCNT,I2C1,I2C1E,I2C1RX,I2C1TX,I2C2,I2C2E,I2C2RX,I2C2TX,INT0,INT1,INT2,IOC,LVD,NCO,NVM,None,OSF,SCAN,SMT1,SMT1PRA,SMT1PWA,SMT2,SMT2PRA,SMT2PWA,SPI1,SPI1RX,SPI1TX,TMR0,TMR1,TMR1G,TMR2,TMR3,TMR3G,TMR4,TMR5,TMR5G,TMR6,U1,U1E,U1RX,U1TX,U2,U2E,U2RX,U2TX,ZCD","text":"None","value":"None"},"id":"Start Trigger_rowCount_1"},"Abort Trigger":{"data":{"isDisable":"true","options":"AD,ADT,CAN_ERRIF,CAN_IRXIF,CAN_RXB0IF\/FIFOIF,CAN_RXB1IF\/RXBnIF,CAN_TXB0IF,CAN_TXB1IF,CAN_TXB2IF\/TXBnIF,CAN_WAKIF,CCP1,CCP2,CCP3,CCP4,CLC1,CLC2,CLC3,CLC4,CMP1,CMP2,CRC,CSW,CWG1,CWG2,CWG3,DMA1A,DMA1DCNT,DMA1OR,DMA1SCNT,DMA2A,DMA2DCNT,DMA2OR,DMA2SCNT,I2C1,I2C1E,I2C1RX,I2C1TX,I2C2,I2C2E,I2C2RX,I2C2TX,INT0,INT1,INT2,IOC,LVD,NCO,NVM,None,OSF,SCAN,SMT1,SMT1PRA,SMT1PWA,SMT2,SMT2PRA,SMT2PWA,SPI1,SPI1RX,SPI1TX,TMR0,TMR1,TMR1G,TMR2,TMR3,TMR3G,TMR4,TMR5,TMR5G,TMR6,U1,U1E,U1RX,U1TX,U2,U2E,U2RX,U2TX,ZCD","text":"None","value":"None"},"id":"Abort Trigger_rowCount_1","Abort Trigger":{"isDisable":"true","options":"AD,ADT,CAN_ERRIF,CAN_IRXIF,CAN_RXB0IF\/FIFOIF,CAN_RXB1IF\/RXBnIF,CAN_TXB0IF,CAN_TXB1IF,CAN_TXB2IF\/TXBnIF,CAN_WAKIF,CCP1,CCP2,CCP3,CCP4,CLC1,CLC2,CLC3,CLC4,CMP1,CMP2,CRC,CSW,CWG1,CWG2,CWG3,DMA1A,DMA1DCNT,DMA1OR,DMA1SCNT,DMA2A,DMA2DCNT,DMA2OR,DMA2SCNT,I2C1,I2C1E,I2C1RX,I2C1TX,I2C2,I2C2E,I2C2RX,I2C2TX,INT0,INT1,INT2,IOC,LVD,NCO,NVM,None,OSF,SCAN,SMT1,SMT1PRA,SMT1PWA,SMT2,SMT2PRA,SMT2PWA,SPI1,SPI1RX,SPI1TX,TMR0,TMR1,TMR1G,TMR2,TMR3,TMR3G,TMR4,TMR5,TMR5G,TMR6,U1,U1E,U1RX,U1TX,U2,U2E,U2RX,U2TX,ZCD","text":"None","value":"None"}}}],"type":"tableDynamicControls","key":"dmaTable"} @@ -17159,27 +17159,7 @@ Window delay time 87.5% - - - mcc_generated_files\mcc.h - aead6835bc73f4332d9abb5de6c2a40829de25cc98452c4c69960d51b52844e9 - - - mcc_generated_files\device_config.h - 2f04b3ff01bbe49769634d389433c7010ffb45d0f2973898e33988be7ab07d56 - - - mcc_generated_files\interrupt_manager.h - 313560861c27e0a0b39b2bbb6a64ac2068fd1937dc0339d7303ff241bbb52955 - - - mcc_generated_files\memory.c - ae2dbb373f8f03dd013cde153de046ba7c3c41033c1dedb8545cde41837ca3da - - - mcc_generated_files\tmr0.h - 68e2ba0f47166abd2da1a472d6a67bfde31f9be3edc8582ace93062a6a32f441 - + main.c 91afd5df6694cfcd0279d66d9b5b3eb72a9c4eae825f0c0af82824e2ee66e35e @@ -17188,6 +17168,46 @@ mcc_generated_files\device_config.c 4288704a051756dce8bb92e77a82ba1285fc638cde56b3676b59406ba0fcea7b + + mcc_generated_files\device_config.h + 2f04b3ff01bbe49769634d389433c7010ffb45d0f2973898e33988be7ab07d56 + + + mcc_generated_files\ecan.c + b60a119876875a2af386474d32176b8be0f47a074a2d8688e79251a2d7cdf6fa + + + mcc_generated_files\ecan.h + 0473fedf57d1376193e049ba507abed0960af84f0e416bea25972c4dae59ca26 + + + mcc_generated_files\interrupt_manager.c + bb0eaf9aec0554de0106cff27f66e56ae02a40bbdcb68d4d58d8a0d84d8929f6 + + + mcc_generated_files\interrupt_manager.h + 313560861c27e0a0b39b2bbb6a64ac2068fd1937dc0339d7303ff241bbb52955 + + + mcc_generated_files\mcc.c + 34fadc3a271040b358215ec477acf3e135b77137f9a1cc96def75fc2936d3ad6 + + + mcc_generated_files\mcc.h + aead6835bc73f4332d9abb5de6c2a40829de25cc98452c4c69960d51b52844e9 + + + mcc_generated_files\memory.c + ae2dbb373f8f03dd013cde153de046ba7c3c41033c1dedb8545cde41837ca3da + + + mcc_generated_files\memory.h + 77a34d015c961db9ed465b4ca2d85ba910fb030ca14c3c2854428ab0b9b6fac2 + + + mcc_generated_files\pin_manager.c + f8ace8a0b0d2a4f0ed3e209db056da57858e5a670ad7d514e44352d9187be806 + mcc_generated_files\pin_manager.h 3e61569926ed5f184a2267965f2cf7ca26dc997d552c213ebd94dbd80da54891 @@ -17197,28 +17217,8 @@ f9702dc8c67433ffc3b8db9e12ee3a73fb0b152a792d26f6c7a89a3846bc4fc9 - mcc_generated_files\pin_manager.c - f8ace8a0b0d2a4f0ed3e209db056da57858e5a670ad7d514e44352d9187be806 - - - mcc_generated_files\ecan.c - b60a119876875a2af386474d32176b8be0f47a074a2d8688e79251a2d7cdf6fa - - - mcc_generated_files\mcc.c - 34fadc3a271040b358215ec477acf3e135b77137f9a1cc96def75fc2936d3ad6 - - - mcc_generated_files\interrupt_manager.c - bb0eaf9aec0554de0106cff27f66e56ae02a40bbdcb68d4d58d8a0d84d8929f6 - - - mcc_generated_files\ecan.h - 0473fedf57d1376193e049ba507abed0960af84f0e416bea25972c4dae59ca26 - - - mcc_generated_files\memory.h - 77a34d015c961db9ed465b4ca2d85ba910fb030ca14c3c2854428ab0b9b6fac2 + mcc_generated_files\tmr0.h + 68e2ba0f47166abd2da1a472d6a67bfde31f9be3edc8582ace93062a6a32f441 \ No newline at end of file diff --git a/UML/watchdog.uxf b/UML/watchdog.uxf index be47bc3..f411877 100644 --- a/UML/watchdog.uxf +++ b/UML/watchdog.uxf @@ -4,8 +4,8 @@ UMLSpecialState - 660 - 225 + 315 + 270 30 30 @@ -15,8 +15,8 @@ Relation - 660 - 240 + 315 + 285 120 105 @@ -27,8 +27,8 @@ evWDinit UMLState - 600 - 315 + 255 + 360 150 60 @@ -38,8 +38,8 @@ evWDinit Relation - 525 - 330 + 180 + 375 270 135 @@ -50,8 +50,8 @@ m1=evWDpoll UMLNote - 825 - 315 + 480 + 360 150 60 @@ -62,8 +62,8 @@ by CAN UMLNote - 720 - 180 + 375 + 225 150 60 From e3f971bb18cbffd6171487a8f5fe5804fca38d07 Mon Sep 17 00:00:00 2001 From: Klagarge Date: Fri, 25 Aug 2023 14:13:51 +0200 Subject: [PATCH 3/7] implement watchdog --- 306-controller_interface.X/app/can_message.c | 12 +++ 306-controller_interface.X/app/can_message.h | 29 ++++++ .../app/factory/factory.c | 14 +++ .../app/factory/factory.h | 8 ++ .../middleware/watchdog.c | 90 +++++++++++++++++++ .../middleware/watchdog.h | 83 +++++++++++++++++ .../nbproject/configurations.xml | 9 +- 7 files changed, 243 insertions(+), 2 deletions(-) create mode 100644 306-controller_interface.X/app/can_message.c create mode 100644 306-controller_interface.X/app/can_message.h create mode 100644 306-controller_interface.X/middleware/watchdog.c create mode 100644 306-controller_interface.X/middleware/watchdog.h diff --git a/306-controller_interface.X/app/can_message.c b/306-controller_interface.X/app/can_message.c new file mode 100644 index 0000000..45645c7 --- /dev/null +++ b/306-controller_interface.X/app/can_message.c @@ -0,0 +1,12 @@ +/** + * @author Rémi Heredero + * @version 1.0.0 + * @date August 2023 + * @file can_message.c + */ + +#include "../middleware/can_interface.h" + +void CM_controller_alive(void* p) { + CAN_Send(0x0, 0xF, 0); +} \ No newline at end of file diff --git a/306-controller_interface.X/app/can_message.h b/306-controller_interface.X/app/can_message.h new file mode 100644 index 0000000..0973672 --- /dev/null +++ b/306-controller_interface.X/app/can_message.h @@ -0,0 +1,29 @@ +/** + * @author Rémi Heredero + * @version 1.0.0 + * @date August 2023 + * @file can_message.h + */ + +#ifndef CAN_MESSAGE_H +#define CAN_MESSAGE_H + + +/* +S R M +1 0 F CONTROL_ALIVE - - - - +1 2 0 JOY_SETUP Mode Param1 Param2 aliveTime +1 3 0 DISPLAY_SETUP reset - - aliveTime +1 3 2 DISPLAY_SPEED valH valL - - +1 3 3 DISPLAY_DIRECTION direction - - - +1 4 0 DRIVE_SETUP Reset/init speedTime stopTime aliveTime +1 4 1 DRIVE_POWER valH valL - - +1 5 0 STEERING_SETUP Reset/init homing setCenter aliveTime +1 5 1 STEERING_SET valHH valH valL valLL +1 6 0 SETUP_CONTROL batteryVoltTime batteryCurrentTime batteryEnergyTime aliveTime +*/ + +void CM_controller_alive(void* p); + +#endif /* CAN_MESSAGE_H */ + diff --git a/306-controller_interface.X/app/factory/factory.c b/306-controller_interface.X/app/factory/factory.c index 2cce0d7..68712a4 100644 --- a/306-controller_interface.X/app/factory/factory.c +++ b/306-controller_interface.X/app/factory/factory.c @@ -30,6 +30,10 @@ LED* l8() { return &theFactory.l8_; } +WATCHDOG* WDcontroller(){ + return &theFactory.WDcontroller_; +} + //initialize all objects void Factory_init() { @@ -54,6 +58,13 @@ void Factory_init() { CAN_init(); CAN_setSender(1); LED_off(l1()); + + // TODO init EPROM interface + + // TODO init watchdog with EPROM CST + WATCHDOG_init(WDcontroller()); + CAR_CST.CONTROL_ALIVE_TIME = 10; + WATCHDOG_setTime(WDcontroller(), CAR_CST.CONTROL_ALIVE_TIME); } void foo(uint8_t a, uint8_t b, uint32_t c){ @@ -69,9 +80,12 @@ void foo(uint8_t a, uint8_t b, uint32_t c){ void Factory_build() { ECAN_SetRXBnInterruptHandler(CAN_newMsg); CAN_onReceiveCan(foo); + + WATCHDOG_onAlive(WDcontroller(), CM_controller_alive, NULL); } //start all state machines void Factory_start() { CAN_startBehaviour(); + WATCHDOG_startBehaviour(WDcontroller()); } diff --git a/306-controller_interface.X/app/factory/factory.h b/306-controller_interface.X/app/factory/factory.h index 737a8e3..df8b9ad 100644 --- a/306-controller_interface.X/app/factory/factory.h +++ b/306-controller_interface.X/app/factory/factory.h @@ -12,9 +12,13 @@ #include #include +#include "../car.h" +#include "../can_message.h" #include "../../board/led/led.h" #include "../../board/button/button.h" +#include "../../middleware/alive_checker.h" #include "../../middleware/can_interface.h" +#include "../../middleware/watchdog.h" typedef struct { @@ -26,6 +30,8 @@ typedef struct { LED l6_; LED l7_; LED l8_; + + WATCHDOG WDcontroller_; } Factory; @@ -44,5 +50,7 @@ LED* l6(); LED* l7(); LED* l8(); +WATCHDOG* WDcontroller(); + #endif \ No newline at end of file diff --git a/306-controller_interface.X/middleware/watchdog.c b/306-controller_interface.X/middleware/watchdog.c new file mode 100644 index 0000000..5840bf5 --- /dev/null +++ b/306-controller_interface.X/middleware/watchdog.c @@ -0,0 +1,90 @@ +/** + * @author Rémi Heredero + * @version 1.0.0 + * @date August 2023 + * @file watchdog.c + */ + +#include "watchdog.h" + +void WATCHDOG_init(WATCHDOG* me){ + me->state = STWD_INIT; + me->time = 10; + me->alive.f = NULL; +} + +void WATCHDOG_startBehaviour(WATCHDOG* me){ + POST(me, &WATCHDOG_processEvent, evWDinit, 0, 0); +} + +bool WATCHDOG_processEvent(Event* ev) { + bool processed = false; + WATCHDOG* me = (WATCHDOG*)Event_getTarget(ev); + WATCHDOG_STATES oldState = me->state; + evIDT evid = Event_getId(ev); + uint64_t data = Event_getData(ev); + + switch (me->state) { // onState + case STWD_INIT: + if (ev->id == evWDinit) { + me->state = STWD_ALIVE; + WATCHDOG_emitPoll(me, 10*me->time, 0); + } + break; + + case STWD_ALIVE: + if (ev->id == evWDpoll) { + WATCHDOG_emitPoll(me, 10*me->time, 0); + if (me->alive.f != NULL) { + me->alive.f(me->alive.p); + } + } + break; + } + + if(oldState != me->state){ + switch (oldState) { // onExit + case STWD_INIT: + break; + + case STWD_ALIVE: + break; + } + + switch (me->state) { // onEntry + case STWD_INIT: + break; + + case STWD_ALIVE: + break; + } + + processed = true; + } + return processed; +} + +/************* + * Callbacks * + *************/ + +void WATCHDOG_onAlive(WATCHDOG* me, WATCHDOG_CALLBACK_FUNCTION f, void* p) { + me->alive.f = f; + me->alive.p = p; +} + +/************ + * EMITTERS * + ************/ + +void WATCHDOG_emitPoll(WATCHDOG* me, uint16_t t, int64_t data) { + POST(me, &WATCHDOG_processEvent, evWDpoll, t, data); +} + +/*********** + * SETTERS * + ***********/ + +void WATCHDOG_setTime(WATCHDOG* me, uint8_t v) { + me->time = v; +} diff --git a/306-controller_interface.X/middleware/watchdog.h b/306-controller_interface.X/middleware/watchdog.h new file mode 100644 index 0000000..ed2d184 --- /dev/null +++ b/306-controller_interface.X/middleware/watchdog.h @@ -0,0 +1,83 @@ +/** + * @author Rémi Heredero + * @version 1.0.0 + * @date August 2023 + * @file watchdog.h + */ +#ifndef WATCHDOG_H +#define WATCHDOG_H + +#include "../xf/xf.h" + +typedef enum { + STWD_INIT, + STWD_ALIVE +} WATCHDOG_STATES; + +typedef enum { + evWDinit = 20, + evWDpoll +} WATCHDOG_EVENTS; + +typedef void (*WATCHDOG_CALLBACK_FUNCTION)(void*); +typedef struct { + WATCHDOG_CALLBACK_FUNCTION f; // function + void* p; // param(s) +} WATCHDOG_CALLBACK; + +typedef struct { + WATCHDOG_STATES state; + uint8_t time; + WATCHDOG_CALLBACK alive; +} WATCHDOG; + +/** + * Initialize the WATCHDOG + * @param me the WATCHDOG itself + */ +void WATCHDOG_init(WATCHDOG* me); + +/** + * Start the WATCHDOG state machine + * @param me the WATCHDOG itself + */ +void WATCHDOG_startBehaviour(WATCHDOG* me); + +/** + * Process the event + * @param ev the event to process + * @return true if the event is processed + */ +bool WATCHDOG_processEvent(Event* ev); + +/************* + * Callbacks * + *************/ + +/** + * Set the callback function to call when the WATCHDOG is entering state alive + * @param me the WATCHDOG itself + * @param f the function to call + * @param p the param(s) to pass to the function + */ +void WATCHDOG_onAlive(WATCHDOG* me, WATCHDOG_CALLBACK_FUNCTION f, void* p); + +/************ + * EMITTERS * + ************/ + +/** + * Emit the poll event + * @param me the WATCHDOG itself + * @param t time to wait in ms before triggering event + * @param data data to put on the event for XF + */ +void WATCHDOG_emitPoll(WATCHDOG* me, uint16_t t, int64_t data); + +/*********** + * SETTERS * + ***********/ + +void WATCHDOG_setTime(WATCHDOG* me, uint8_t v); + +#endif diff --git a/306-controller_interface.X/nbproject/configurations.xml b/306-controller_interface.X/nbproject/configurations.xml index 11b024b..0fc2e44 100644 --- a/306-controller_interface.X/nbproject/configurations.xml +++ b/306-controller_interface.X/nbproject/configurations.xml @@ -7,6 +7,7 @@ app/factory/factory.h app/car.h + app/can_message.h board/led/led.h @@ -25,6 +26,7 @@ middleware/can_interface.h middleware/alive_checker.h + middleware/watchdog.h xf/event.h @@ -41,6 +43,7 @@ projectFiles="true"> app/factory/factory.c + app/can_message.c board/led/led.c @@ -59,6 +62,7 @@ middleware/can_interface.c middleware/alive_checker.c + middleware/watchdog.c xf/event.c @@ -210,6 +214,7 @@ + @@ -240,7 +245,7 @@ - + @@ -285,7 +290,7 @@ - + From deba3fbf0d6b48c7897827356d71a717b996d751 Mon Sep 17 00:00:00 2001 From: Klagarge Date: Fri, 25 Aug 2023 15:25:40 +0200 Subject: [PATCH 4/7] fix config --- 306-controller_interface.X/nbproject/configurations.xml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/306-controller_interface.X/nbproject/configurations.xml b/306-controller_interface.X/nbproject/configurations.xml index 0fc2e44..4b844cc 100644 --- a/306-controller_interface.X/nbproject/configurations.xml +++ b/306-controller_interface.X/nbproject/configurations.xml @@ -95,7 +95,7 @@ 3 - + @@ -214,7 +214,6 @@ - @@ -300,12 +299,15 @@ + + + From 88096a007c1b462153286531d5da3a56833d3d86 Mon Sep 17 00:00:00 2001 From: Klagarge Date: Fri, 25 Aug 2023 18:23:36 +0200 Subject: [PATCH 5/7] create alive_checker --- 306-controller_interface.X/app/can_message.c | 91 ++++++++++++++++++- 306-controller_interface.X/app/can_message.h | 13 ++- 306-controller_interface.X/app/car.h | 35 ++++--- .../app/factory/factory.c | 22 ++++- .../app/factory/factory.h | 2 + .../middleware/alive_checker.c | 2 +- .../middleware/can_interface.c | 8 +- 7 files changed, 149 insertions(+), 24 deletions(-) diff --git a/306-controller_interface.X/app/can_message.c b/306-controller_interface.X/app/can_message.c index 45645c7..a746c18 100644 --- a/306-controller_interface.X/app/can_message.c +++ b/306-controller_interface.X/app/can_message.c @@ -6,7 +6,94 @@ */ #include "../middleware/can_interface.h" +#include "car.h" +#include "../app/factory/factory.h" -void CM_controller_alive(void* p) { +typedef union { + struct { + uint8_t byte0; + uint8_t byte1; + uint8_t byte2; + uint8_t byte3; + } separate; + struct { + uint32_t bytes; + } full; +} BYTES_4; + +void CM_processIncome(uint8_t idSender, uint8_t idMsg, uint32_t data){ + switch(idSender){ + case 0: // Broadcast / Debug + break; + + case 2: // Joystick + if(idMsg == 0x1) { // JOY_MESURE + + } + + if(idMsg == 0xF) { // JOY_ALIVE + ALIVE_CHECKER_ISALIVE(ACjoy()); + } + break; + + case 3: // Display + break; + + case 4: // Drive + break; + + case 5: // Steering + break; + + case 6: // Supply + break; + + case 7: // Undefined + break; + } +} + +void CM_CONTROLLER_ALIVE(void* p) { CAN_Send(0x0, 0xF, 0); -} \ No newline at end of file +} + +void CM_JOY_SETUP(void* p) { + BYTES_4 joy; + joy.separate.byte0 = CAR_CST.JOYSTICK_MODE; + joy.separate.byte1 = CAR_CST.JOYSTICK_PARAM1; + joy.separate.byte2 = CAR_CST.JOYSTICK_PARAM2; + joy.separate.byte3 = CAR_CST.JOYSTICK_ALIVE_TIME; + CAN_Send(2, 0, joy.full.bytes); + +} +void CM_DISPLAY_SETUP(void* p) { + +} + +void CM_DISPLAY_SPEED(void* p) { + +} + +void CM_DISPLAY_DIRECTION(void* p) { + +} + +void CM_DRIVE_SETUP(void* p) { + +} + +void CM_DRIVE_POWER(void* p) { + +} + +void CM_STEERING_SETUP(void* p) { + +} + +void CM_STEERING_SET(void* p) { + +} + +void CM_SETUP_CONTROL(void* p) { + +} diff --git a/306-controller_interface.X/app/can_message.h b/306-controller_interface.X/app/can_message.h index 0973672..cfec699 100644 --- a/306-controller_interface.X/app/can_message.h +++ b/306-controller_interface.X/app/can_message.h @@ -23,7 +23,18 @@ S R M 1 6 0 SETUP_CONTROL batteryVoltTime batteryCurrentTime batteryEnergyTime aliveTime */ -void CM_controller_alive(void* p); +void CM_processIncome(uint8_t idSender, uint8_t idMsg, uint32_t data); +void CM_CONTROLLER_ALIVE(void* p); +void CM_JOY_SETUP(void* p); +void CM_DISPLAY_SETUP(void* p); +void CM_DISPLAY_SPEED(void* p); +void CM_DISPLAY_DIRECTION(void* p); +void CM_DRIVE_SETUP(void* p); +void CM_DRIVE_POWER(void* p); +void CM_STEERING_SETUP(void* p); +void CM_STEERING_SET(void* p); +void CM_SETUP_CONTROL(void* p); + #endif /* CAN_MESSAGE_H */ diff --git a/306-controller_interface.X/app/car.h b/306-controller_interface.X/app/car.h index 93513bf..5d3a9a8 100644 --- a/306-controller_interface.X/app/car.h +++ b/306-controller_interface.X/app/car.h @@ -23,20 +23,23 @@ /******************* * MEMORY ADRESSES * *******************/ -#define MEMADD_CONTROL_STEERING_MODE 0x00 -#define MEMADD_CONTROL_ALIVE_TIME 0x01 -#define MEMADD_CONTROL_SPEED_FACTOR 0x02 -#define MEMADD_CONTROL_POWER_FACTOR 0x06 -#define MEMADD_CONTROL_STEERING_FACTOR 0x0A -#define MEMADD_CONTROL_MAX_SPEED_FW 0x0E -#define MEMADD_CONTROL_MAX_SPEED_BW 0x0F -#define MEMADD_JOYSTICK_ALIVE_TIME 0x10 -#define MEMADD_DISPLAY_ALIVE_TIME 0x11 -#define MEMADD_DRIVE_SPEED_TIME 0x12 -#define MEMADD_DRIVE_STOP_TIME 0x13 -#define MEMADD_DRIVE_ALIVE_TIME 0x14 -#define MEMADD_STEERING_ALIVE_TIME 0x15 -#define MEMADD_BATTERY_ALIVE_TIME 0x16 +#define MEMADD_CONTROL_STEERING_MODE 0x01 +#define MEMADD_CONTROL_ALIVE_TIME 0x02 +#define MEMADD_CONTROL_SPEED_FACTOR 0x03 +#define MEMADD_CONTROL_POWER_FACTOR 0x07 +#define MEMADD_CONTROL_STEERING_FACTOR 0x0B +#define MEMADD_CONTROL_MAX_SPEED_FW 0x0F +#define MEMADD_CONTROL_MAX_SPEED_BW 0x10 +#define MEMADD_JOYSTICK_MODE 0x11 +#define MEMADD_JOYSTICK_PARAM1 0x12 +#define MEMADD_JOYSTICK_PARAM2 0x13 +#define MEMADD_JOYSTICK_ALIVE_TIME 0x14 +#define MEMADD_DISPLAY_ALIVE_TIME 0x +#define MEMADD_DRIVE_SPEED_TIME 0x +#define MEMADD_DRIVE_STOP_TIME 0x +#define MEMADD_DRIVE_ALIVE_TIME 0x +#define MEMADD_STEERING_ALIVE_TIME 0x +#define MEMADD_BATTERY_ALIVE_TIME 0x typedef struct { uint8_t CONTROL_STEERING_MODE; @@ -46,6 +49,10 @@ typedef struct { uint32_t CONTROL_STEERING_FACTOR; uint8_t CONTROL_MAX_SPEED_FW; uint8_t CONTROL_MAX_SPEED_BW; + + uint8_t JOYSTICK_MODE; + uint8_t JOYSTICK_PARAM1; + uint8_t JOYSTICK_PARAM2; uint8_t JOYSTICK_ALIVE_TIME; uint8_t DISPLAY_ALIVE_TIME; uint8_t DRIVE_SPEED_TIME; diff --git a/306-controller_interface.X/app/factory/factory.c b/306-controller_interface.X/app/factory/factory.c index 68712a4..63150e8 100644 --- a/306-controller_interface.X/app/factory/factory.c +++ b/306-controller_interface.X/app/factory/factory.c @@ -34,6 +34,10 @@ WATCHDOG* WDcontroller(){ return &theFactory.WDcontroller_; } +ALIVE_CHECKER* ACjoy() { + return &theFactory.ACjoy_; +} + //initialize all objects void Factory_init() { @@ -63,8 +67,15 @@ void Factory_init() { // TODO init watchdog with EPROM CST WATCHDOG_init(WDcontroller()); - CAR_CST.CONTROL_ALIVE_TIME = 10; + CAR_CST.CONTROL_ALIVE_TIME = 100; WATCHDOG_setTime(WDcontroller(), CAR_CST.CONTROL_ALIVE_TIME); + + // TODO init ALIVE CHECKER with EPROM CST + CAR_CST.JOYSTICK_MODE = 0; + CAR_CST.JOYSTICK_PARAM1 = 100; + CAR_CST.JOYSTICK_PARAM2 = 1; + CAR_CST.JOYSTICK_ALIVE_TIME = 10; + ALIVE_CHECKER_init(ACjoy()); } void foo(uint8_t a, uint8_t b, uint32_t c){ @@ -81,11 +92,18 @@ void Factory_build() { ECAN_SetRXBnInterruptHandler(CAN_newMsg); CAN_onReceiveCan(foo); - WATCHDOG_onAlive(WDcontroller(), CM_controller_alive, NULL); + WATCHDOG_onAlive(WDcontroller(), CM_CONTROLLER_ALIVE, NULL); + ALIVE_CHECKER_onSetup(ACjoy(), CM_JOY_SETUP, NULL); + ALIVE_CHECKER_setAliveTime(ACjoy(), CAR_CST.JOYSTICK_ALIVE_TIME); + } //start all state machines void Factory_start() { CAN_startBehaviour(); WATCHDOG_startBehaviour(WDcontroller()); + ALIVE_CHECKER_startBehaviour(ACjoy()); + ALIVE_CHECKER_emitBorn(ACjoy(), 100, 0); + ALIVE_CHECKER_emitReady(ACjoy(), 200, 0); + } diff --git a/306-controller_interface.X/app/factory/factory.h b/306-controller_interface.X/app/factory/factory.h index df8b9ad..015a4ba 100644 --- a/306-controller_interface.X/app/factory/factory.h +++ b/306-controller_interface.X/app/factory/factory.h @@ -32,6 +32,7 @@ typedef struct { LED l8_; WATCHDOG WDcontroller_; + ALIVE_CHECKER ACjoy_; } Factory; @@ -51,6 +52,7 @@ LED* l7(); LED* l8(); WATCHDOG* WDcontroller(); +ALIVE_CHECKER* ACjoy(); #endif \ No newline at end of file diff --git a/306-controller_interface.X/middleware/alive_checker.c b/306-controller_interface.X/middleware/alive_checker.c index 9128429..7dace84 100644 --- a/306-controller_interface.X/middleware/alive_checker.c +++ b/306-controller_interface.X/middleware/alive_checker.c @@ -56,6 +56,7 @@ bool ALIVE_CHECKER_processEvent(Event* ev) { } else { me->state = STAC_DEAD; } + me->isAlive = false; } break; @@ -101,7 +102,6 @@ bool ALIVE_CHECKER_processEvent(Event* ev) { break; case STAC_WAIT: - me->isAlive = false; if (me->wait.f != NULL) { me->wait.f(me->wait.p); } diff --git a/306-controller_interface.X/middleware/can_interface.c b/306-controller_interface.X/middleware/can_interface.c index ec598b9..e346a7a 100644 --- a/306-controller_interface.X/middleware/can_interface.c +++ b/306-controller_interface.X/middleware/can_interface.c @@ -88,13 +88,13 @@ bool CAN_processEvent(Event* ev) { canMsg.frame.idType = dSTANDARD_CAN_MSG_ID_2_0B; // standard canMsg.frame.dlc = 4; // 4 bytes to send canMsg.frame.rtr = 0; // no remote frame - canMsg.frame.data3 = (uint8_t) data; - data = data >> 8; - canMsg.frame.data2 = (uint8_t) data; + canMsg.frame.data0 = (uint8_t) data; data = data >> 8; canMsg.frame.data1 = (uint8_t) data; data = data >> 8; - canMsg.frame.data0 = (uint8_t) data; + canMsg.frame.data2 = (uint8_t) data; + data = data >> 8; + canMsg.frame.data3 = (uint8_t) data; data = data >> 8; canMsg.frame.id = (uint32_t) data; CAN_transmit(&canMsg); From 0d766220edce901b3086da8679a0584850b27634 Mon Sep 17 00:00:00 2001 From: Klagarge Date: Fri, 25 Aug 2023 18:35:01 +0200 Subject: [PATCH 6/7] implement alive_checker --- 306-controller_interface.X/app/factory/factory.c | 13 +++---------- .../middleware/alive_checker.c | 2 +- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/306-controller_interface.X/app/factory/factory.c b/306-controller_interface.X/app/factory/factory.c index 63150e8..2f62bfd 100644 --- a/306-controller_interface.X/app/factory/factory.c +++ b/306-controller_interface.X/app/factory/factory.c @@ -78,23 +78,16 @@ void Factory_init() { ALIVE_CHECKER_init(ACjoy()); } -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 void Factory_build() { ECAN_SetRXBnInterruptHandler(CAN_newMsg); - CAN_onReceiveCan(foo); + CAN_onReceiveCan(CM_processIncome); WATCHDOG_onAlive(WDcontroller(), CM_CONTROLLER_ALIVE, NULL); ALIVE_CHECKER_onSetup(ACjoy(), CM_JOY_SETUP, NULL); ALIVE_CHECKER_setAliveTime(ACjoy(), CAR_CST.JOYSTICK_ALIVE_TIME); + ALIVE_CHECKER_onBorn(ACjoy(), LED_on, l1()); + ALIVE_CHECKER_onDead(ACjoy(), LED_off, l1()); } diff --git a/306-controller_interface.X/middleware/alive_checker.c b/306-controller_interface.X/middleware/alive_checker.c index 7dace84..00466a4 100644 --- a/306-controller_interface.X/middleware/alive_checker.c +++ b/306-controller_interface.X/middleware/alive_checker.c @@ -168,7 +168,7 @@ void ALIVE_CHECKER_setAliveTime(ALIVE_CHECKER* me, uint8_t v) { } void ALIVE_CHECKER_setIsAlive(ALIVE_CHECKER* me, bool v) { - me->aliveTime = v; + me->isAlive = v; } void ALIVE_CHECKER_ISALIVE(ALIVE_CHECKER* me) { From ae84c45e1c15bcbe9093c3c8864b4745afb37475 Mon Sep 17 00:00:00 2001 From: Klagarge Date: Fri, 25 Aug 2023 18:40:52 +0200 Subject: [PATCH 7/7] add config for busmaster --- busmaster_config.cfx | 588 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 588 insertions(+) create mode 100644 busmaster_config.cfx diff --git a/busmaster_config.cfx b/busmaster_config.cfx new file mode 100644 index 0000000..94c32ac --- /dev/null +++ b/busmaster_config.cfx @@ -0,0 +1,588 @@ + + + + 3.2.2 + FALSE + FALSE + FALSE + FALSE + FALSE + FALSE + FALSE + TRUE + SYSTEM + FALSE + FALSE + FALSE + FALSE + + SHOWNORMAL + HIDE + 655 + 0 + 874 + 1532 + + + + + threewheeler.DBF + + + + MHS Tiny-CAN + Bus Off + + + 250 + 7 + B8 + 5 + 00 + 1C + 16 + 75 + 1 + 10 + 96 + ALL + 4 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + FF + FF + FF + FF + FF + FF + FF + FF + Simulation + 64 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + + 0 + 2000000 + 70 + 10 + 3 + 0 + 0 + + + + + + 288 + DeltaY + aliveTime + timeMeasureOrDeltaX + mode + + + SHOWNORMAL + HIDE + 622 + 86 + 816 + 998 + + + 142 + 174 + 285 + 142 + + + + + SHOWNORMAL + HIDE + 70 + 10 + 500 + 300 + + + 87 + 87 + 174 + 87 + + + + + SHOWNORMAL + HIDE + 70 + 10 + 500 + 300 + + + 87 + 87 + 174 + 87 + + + + + 5000 + 1000 + 21760 + 1 + 0 + 12632256 + 255 + 10 + 5 + 2 + 0 + TRUE + NORMAL + + + HIDE + HIDE + -1 + 0 + 0 + 0 + + + -1 + 0 + + + 0 + 0 + + + 0 + 0 + + + 0 + 0 + + + + 0 + + + 0 + + + 0 + + + + HIDE + RESTORETOMAXIMIZED + 0 + 0 + 0 + 0 + + + + + HIDE + RESTORETOMAXIMIZED + 0 + 0 + 0 + 0 + + + + + 5000 + 2000 + 100 + + + 1 + 0 + 0 + + + Time + 2 + 1 + 138 + + + Tx/Rx + 3 + 1 + 85 + + + Channel + 4 + 1 + 92 + + + Msg Type + 5 + 1 + 71 + + + ID + 6 + 1 + 69 + + + Message + 7 + 1 + 174 + + + DLC + 8 + 1 + 75 + + + Data Byte(s) + 9 + 1 + 198 + + 1 + 0 + 0 + SYSTEM + + SHOWNORMAL + RESTORETOMAXIMIZED + 0 + 0 + 295 + 909 + + + SHOWNORMAL + RESTORETOMAXIMIZED + 271 + 879 + 958 + 1552 + + + + + + 1 + 0 + 0 + + + Time + 2 + 1 + 91 + + + Channel + 3 + 1 + 88 + + + CAN ID + 4 + 1 + 88 + + + PGN + 5 + 1 + 84 + + + PGN Name + 6 + 1 + 118 + + + Type + 7 + 1 + 75 + + + Src + 8 + 1 + 60 + + + Dest + 9 + 1 + 57 + + + Priority + 10 + 1 + 74 + + + Tx/Rx + 11 + 1 + 73 + + + DLC + 12 + 1 + 70 + + + Data Byte(s) + 13 + 1 + 720 + + 1 + 0 + 0 + SYSTEM + + SHOWNORMAL + RESTORETOMAXIMIZED + 0 + 0 + 543 + 1614 + + + SHOWNORMAL + RESTORETOMAXIMIZED + 179 + 10 + 457 + 359 + + + + 5000 + 2000 + 100 + + + 1 + 0 + 0 + + + Time + 2 + 1 + 95 + + + Message + 3 + 1 + 99 + + + Message Type + 4 + 1 + 135 + + + Tx/Rx + 5 + 1 + 85 + + + Channel + 6 + 1 + 80 + + + DLC + 7 + 1 + 70 + + + ID + 8 + 1 + 65 + + + Data Byte(s) + 9 + 1 + 235 + + + Checksum + 10 + 1 + 734 + + 1 + 0 + 0 + SYSTEM + + SHOWNORMAL + RESTORETOMAXIMIZED + 0 + 0 + 543 + 1614 + + + SHOWNORMAL + RESTORETOMAXIMIZED + 179 + 10 + 457 + 359 + + + + + SHOWNORMAL + SETMINPOSITION + 12 + 989 + 667 + 1849 + + + + 1 + 528 + FALSE + FALSE + 4 + 0,0,0,0 + 10 + FALSE + a + FALSE + + + 1 + 529 + FALSE + FALSE + 4 + 0,0,0,0 + 10 + FALSE + a + FALSE + + + 1 + 288 + FALSE + FALSE + 4 + 0,255,1,5 + 10 + FALSE + a + FALSE + + + 1 + 543 + FALSE + FALSE + 1 + 0 + 10 + FALSE + a + FALSE + + + + + 125 + 1 + + + + HIDE + RESTORETOMAXIMIZED + 0 + 0 + 0 + 0 + + + + + 0 + Hardware + 19200 + LIN 2.0 + 1 + 0 + + + + + + SHOWNORMAL + SETMINPOSITION + 1 + 4 + 661 + 864 + + + + + + SHOWNORMAL + SETMINPOSITION + 183 + 535 + 716 + 1185 + + + 1 + + + +