Skip to content

Commit

Permalink
fix for update E220(v2.0.2)
Browse files Browse the repository at this point in the history
  • Loading branch information
nihinihikun committed Mar 19, 2024
1 parent 848bb91 commit 3b6b1c1
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 467 deletions.
2 changes: 1 addition & 1 deletion test/E220_can/E220_can.ino
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#define SEND_PERIOD_MS 1000

E220 e220(0xFF, 0xFF, 0x00); //TARGETADRESS=0xFFFF,CHANNEL=0x00
E220 e220(Serial1,0xFF, 0xFF, 0x00); //TARGETADRESS=0xFFFF,CHANNEL=0x00
CCP_MCP2515 CCP(CAN0_CS, CAN0_INT); //CAN

/*E220configuration
Expand Down
2 changes: 1 addition & 1 deletion test/E220_ground/E220_ground.ino
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#define SEND_PERIOD_MS 1000

E220 e220(0xFF, 0xFF, 0x0A); //TARGETADRESS=0xFFFF,CHANNEL=0x0A=10ch=ARIB 34-35
E220 e220(Serial1,0xFF, 0xFF, 0x0A); //TARGETADRESS=0xFFFF,CHANNEL=0x0A=10ch=ARIB 34-35

/*E220configuration
- UARTbaudrate:115200bps
Expand Down
2 changes: 1 addition & 1 deletion test/E220_vertual_rocket/E220_vertual_rocket.ino
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#define SEND_PERIOD_MS 1000

E220 e220(0xFF, 0xFF, 0x0A); //TARGETADRESS=0xFFFF,CHANNEL=0x0A=10ch=ARIB 34-35
E220 e220(Serial1,0xFF, 0xFF, 0x0A); //TARGETADRESS=0xFFFF,CHANNEL=0x0A=10ch=ARIB 34-35

/*E220configuration
- UARTbaudrate:115200bps
Expand Down
26 changes: 17 additions & 9 deletions test/MIFE220/MIFcan/MIFcan.ino
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
#define CAN0_CS 0
#define CAN0_INT 1

#define SEND_PERIOD_MS 1000
#define PAYLOAD_SIZE 47
#define ROCKET_INSIDE_PACKET_LETTER 0x4E

E220 e220(0xFF, 0xFF, 0x0A); //TARGETADRESS=0xFFFF,CHANNEL=0x0A=10ch=ARIB 34-35
CCP_MCP2515 CCP(CAN0_CS, CAN0_INT); //CAN

/*E220configuration
Expand All @@ -28,8 +28,6 @@ union unionuint32 {
byte b[4];
};



void setup() {
Serial1.setFIFOSize(512); //E220のサブパケ200byteより大きいサイズにする
Serial.begin(9600);
Expand All @@ -39,13 +37,23 @@ void setup() {

void loop() {
static byte tx_payload[199] = { 0 };
static bool send_allowed = false; //送信許可
static byte rocket_inside_packet[200]={0};
static bool payload_semapho = false; //payloadの生成が終わるまで送信を許可しない
static uint32_t latest_send_time = 0; //最後に送信した時間
GeneratePayload(tx_payload, payload_semapho);

//ToDO:tx_payloadをMain基板に送信する処理を書く

//tx_payloadをMain基板に送信する処理
if (payload_semapho == false) {
SendMainDataPacket(tx_payload);
}
}

void SendMainDataPacket(byte* _tx_payload){
byte rocket_inside_packet[200]={0};
rocket_inside_packet[0] = ROCKET_INSIDE_PACKET_LETTER;// Mainマイコンがどっからデータか判断するための識別子
for (int i = 0; i < PAYLOAD_SIZE; i++) {
rocket_inside_packet[i+1] = _tx_payload[i];
}
//main基板に送信
Serial1.write(rocket_inside_packet, 200);//一個目が識別子,後ろがデータ
}

void GeneratePayload(byte* tx_payload, bool _payload_semapho) {
Expand Down
31 changes: 17 additions & 14 deletions test/MIFE220/MainE220/MainE220.ino
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,11 @@

#define SEND_PERIOD_MS 1000//E220のダウンリンクの周期(ms)

E220 e220(0xFF, 0xFF, 0x0A); //TARGETADRESS=0xFFFF,CHANNEL=0x0A
CCP_MCP2515 CCP(CAN0_CS, CAN0_INT); //CAN
#define PAYLOAD_SIZE 47
#define ROCKET_INSIDE_PACKET_LETTER 0x4E

/*E220configuration
- UARTbaudrate:115200bps
- bandwith: 250kHz//審査書の値なので運営からの指示以外変更禁止
- channel: 0x0A(ARIB 34-35)//審査書の値なので運営からの指示以外変更禁止
- target address: 0xFFFF(broradcast)
- power: 13dBm
- SF: 11
*/
E220 e220(Serial2,0xFF, 0xFF, 0x0A); //TARGETADRESS=0xFFFF,CHANNEL=0x0A
CCP_MCP2515 CCP(CAN0_CS, CAN0_INT); //CAN


union unionfloat {
Expand All @@ -33,18 +27,25 @@ union unionuint32 {
void setup() {
Serial1.setFIFOSize(512); //E220のサブパケ200byteより大きいサイズにする
Serial.begin(9600);
Serial1.begin(115200); //E220のUART
Serial1.begin(115200); //MIFとつながってるUART
Serial2.begin(115200); //E220のUART
CCP.begin();
}

void loop() {
static byte tx_payload[199] = { 0 };//MIF基板から送られるbyte配列格納先
static bool send_allowed = false; //送信許可
static uint32_t latest_send_time = 0; //最後に送信した時間
static bool comingdata = false; //MIF基板からデータが来ているか

//TODO:ここにMIF基板からのデータを受け取ってtx_payloadにいれる処理を書く

if ((millis() - latest_send_time) > SEND_PERIOD_MS) { //前の送信から一定時間経過しているか
//MIF基板からのデータを受け取ってtx_payloadにいれる処理
if(Serial1.readBytesUntil(ROCKET_INSIDE_PACKET_LETTER,tx_payload,PAYLOAD_SIZE)){
comingdata = true;
}else{
comingdata = false;
}
//ここから送信処理
if (((millis() - latest_send_time) > SEND_PERIOD_MS)&& comingdata) { //前の送信から一定時間経過しているか
send_allowed = true;
}
if (send_allowed == true) {
Expand All @@ -53,3 +54,5 @@ void loop() {
send_allowed = false;
}
}


38 changes: 0 additions & 38 deletions test/formerE220lib/E220/E220.ino

This file was deleted.

168 changes: 0 additions & 168 deletions test/formerE220lib/E220_can/E220_can.ino

This file was deleted.

Loading

0 comments on commit 3b6b1c1

Please sign in to comment.