主题中讨论的其他器件:LAUNCHXL2-570LC43
// set pin numbers: const int wake = 8; // module wake pin const int fault = 9; // module fault pin void setup() { // initialize the pins: pinMode(wake, OUTPUT); pinMode(fault, INPUT_PULLUP); pinMode(18, OUTPUT); pinMode(19, OUTPUT); // wake sequence digitalWrite(wake, LOW); delayMicroseconds(250); digitalWrite(wake, HIGH); delay(7); //tSU(WAKE) transition time from shutdown to active - 7ms from wake receive to wake propagate for each device digitalWrite(19, LOW); digitalWrite(18, HIGH); delayMicroseconds(250); digitalWrite(19, HIGH); digitalWrite(18, LOW); //enable serial Serial.begin(9600); Serial1.begin(250000); //Autoaddress //dummy write to ECC_TEST (sync DLL) // WriteReg(0, ECC_TEST, 0x00, 1, FRMWRT_ALL_NR); byte ECC_TEST[] = { 0xD0, 0x01, 0x1D, 0x00, 0x60, 0x74 }; sendData(ECC_TEST, sizeof(ECC_TEST)); //clear CONFIG in case it is set // WriteReg(0, CONFIG, 0x00, 1, FRMWRT_ALL_NR); byte CONFIG[] = { 0xD0, 0x00, 0x01, 0x00, 0x39, 0x74 }; sendData(CONFIG, sizeof(CONFIG)); //enter auto addressing mode // WriteReg(0, CONTROL1, 0x01, 1, FRMWRT_ALL_NR); byte CONTROL1[] = { 0xD0, 0x01, 0x05, 0x01, 0xAB, 0xB4 }; sendData(CONTROL1, sizeof(CONTROL1)); //set addresses for all boards in daisy-chain // WriteReg(0, DEVADD_USR, 0, 1, FRMWRT_ALL_NR); byte DEVADD_USR[] = { 0x90, 0x00, 0x00, 0x01, 0x01, 0x24, 0x4D }; sendData(DEVADD_USR, sizeof(DEVADD_USR)); // for (nCurrentBoard = 0; nCurrentBoard < TOTALBOARDS; nCurrentBoard++) { // WriteReg(nCurrentBoard, DEVADD_USR, nCurrentBoard, 1, FRMWRT_ALL_NR); // } sendData(ECC_TEST, sizeof(ECC_TEST)); //Set comm timeout byte message1[] = { 0xD0, 0x00, 0x23, 0x00, 0x21, 0xD4 }; sendData(message1, sizeof(message1)); //Set transmit delay byte message2[] = { 0xD0, 0x00, 0x22, 0x00, 0x20, 0x44 }; sendData(message2, sizeof(message2)); // //Read part ID // byte message3[] = { 0x80, 0x00, 0x02, 0x00, 0x00, 0x84, 0x1E }; // Serial1.write(message3, sizeof(message3)); // int incomingByte = 0; // Serial.println("Setup Done"); // while (!Serial1.available()) // Serial.println(digitalRead(fault)); // Serial.println("Got FB"); // if (Serial1.available()) { // incomingByte = Serial1.read(); // read the incoming byte: // Serial.print(" Part ID:"); // Serial.println(incomingByte); // } // GPIO 1 Config as O/P // WriteReg(0, GPIO1_CONF, 0x14, 1, FRMWRT_ALL_NR); byte GPIO1_CONF[] = { 0x90, 0x00, 0x00, 0x2F, 0x14, 0x01, 0x00, 0xC2, 0x49 }; sendData(GPIO1_CONF, sizeof(GPIO1_CONF)); } void loop() { // byte message[] = {0xAA, 0xBB, 0x06, 0x00, 0x00, 0x00, 0x01, 0x01, 0x03, 0x03 }; // Serial.write(message, sizeof(message)); digitalWrite(wake, LOW); delayMicroseconds(250); digitalWrite(wake, HIGH); // WriteReg(0, GPIO_OUT, 0x01, 1, FRMWRT_ALL_R); byte GPIO1_OUT_ON[] = { 0x90, 0x00, 0x01, 0x08, 0x01, 0x01, 0x00, 0xE4, 0xF9 }; sendData(GPIO1_OUT_ON, sizeof(GPIO1_OUT_ON)); delay(5000); // WriteReg(0, GPIO_OUT, 0x00, 1, FRMWRT_ALL_R); byte GPIO1_OUT_OFF[] = { 0x90, 0x00, 0x01, 0x08, 0x00, 0x01, 0x00, 0xB5, 0x39 }; sendData(GPIO1_OUT_OFF, sizeof(GPIO1_OUT_OFF)); delay(5000); } void sendData(byte *data, size_t length) { for (int i = 0; i < length; i++) { Serial1.write(data[i]); } delay(1000); }
请说明我做错了什么?