電動バイク制御基板プログラム
Dependencies: BufferedSerial SDFileSystem mbed
main.cpp
- Committer:
- NT32
- Date:
- 2016-11-05
- Revision:
- 2:1a62df057057
- Parent:
- 1:f61fbb8e4352
File content as of revision 2:1a62df057057:
#include "mbed.h" #include "SDFileSystem.h" #define SEL_GPS 0 #define SEL_BMS 1 #define SEL_HNDL 2 #define SEL_FELICA 3 #define CELL_NUM 24 DigitalOut led1(P1_1); DigitalOut led2(P0_9); BusOut selUart(P1_5, P1_4); //Serial uart_cpld(P1_0, P0_31); //Serial uart_v850(P0_28, P0_29); //Serial uart_gps(P0_26, P0_27); //↓txをCPLDにして,rxをV850にする Serial uart_handle(P0_0, P1_3); //<=(tx,rx)で,今は rx->tx と素通り //Serial uart_felica(P0_4, P0_2); Serial pc(P0_18,P0_13); //SDFileSystem sd(P0_7, P0_5, P0_6, P0_8, "sd"); int main() { int cellVol[CELL_NUM] = {0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0}; int cellMinVol, cellMaxVol, cellAvgVol; char buff[32]; uart_handle.baud(38400); // selUartがマルチプレクサのピン selUart = SEL_HNDL; while(1) { led1 = !led1; uart_handle.scanf("%s", buff); if(buff[0] == 's'){ // pc.printf("\033[%d;%dH" ,0,0); //デバッグ用Tera Term出力 // pc.printf("%s\n", buff); uart_handle.printf("%s\n", buff); } //================================================= // バッテリ管理基板との通信 //================================================= // led1 = 0; // selUart = SEL_BMS; // uart_cpld.putc('s'); // for (int i = 0; i < CELL_NUM; ++i) // { // // 個別セル電圧取得 // uart_cpld.scanf("%d\n", &cellVol[i]); // } // //最低->最高->平均で取得 // uart_cpld.scanf("%d\n", &cellMinVol); // uart_cpld.scanf("%d\n", &cellMaxVol); // uart_cpld.scanf("%d\n", &cellAvgVol); // led1 = 1; //================================================= // 表示装置との通信 //================================================= // led2 = 0; // selUart = SEL_HNDL; // uart_cpld.putc('m'); // uart_cpld.printf("\033[2J"); //デバッグ用Tera Term出力 // uart_cpld.printf("\033[%d;%dH" ,0,0); //デバッグ用Tera Term出力 // // wait(0.01); // for (int i = 0; i < CELL_NUM; ++i) // { // // 個別セル電圧取得 // uart_cpld.printf("%d\n",cellVol[i]); // } // //最低->最高->平均で取得 // uart_cpld.printf("%d\n",cellMinVol); // uart_cpld.printf("%d\n",cellMaxVol); // uart_cpld.printf("%d\n",cellAvgVol); // // led2 = 1; } }