Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 /* mbed Microcontroller Library 00002 * Copyright (c) 2019 ARM Limited 00003 * SPDX-License-Identifier: Apache-2.0 00004 */ 00005 00006 #include "mbed.h" 00007 #include "platform/mbed_thread.h" 00008 00009 00010 DigitalOut led1(PB_4); 00011 DigitalOut led2(PB_12); 00012 DigitalOut BT_RST(PB_5); 00013 InterruptIn Button (PC_13); 00014 DigitalOut Stby_can(PD_3); 00015 DigitalOut re_5v(PB_10); 00016 Serial RS232_2(PC_12, PE_7); 00017 Serial RS485(PC_6, PC_7); 00018 Serial BT(PA_9, PA_10); 00019 00020 //Ticker ticker; 00021 00022 CAN can1(PD_0, PD_1); 00023 char counter = 'a'; 00024 char counter1 = 'b'; 00025 char counter2 = 'c'; 00026 char counter3 = 'd'; 00027 char counter4 = 'e'; 00028 char counter5 = 'f'; 00029 char counter6 = 'g'; 00030 char counter7 = 'h'; 00031 00032 int main() { 00033 led2 = 1; 00034 re_5v = 1; 00035 Stby_can = 0; 00036 led1 = 0; 00037 BT_RST = 1; 00038 wait_ms(5000); 00039 CANMessage msg1; 00040 CANMessage msg2; 00041 CANMessage msg3; 00042 // msg.format = CANExtended;// or CANExtended; // standard or extended ID (can be skipped for standard) 00043 msg1.id = 1337; 00044 msg1.len = 8;//length in bytes (1 to 8); 00045 //msg1.data[0] = 1; // repeat for each byte. 00046 //msg1.data[1] = 2; 00047 //msg1.data[2] = 3; 00048 //msg1.data[3] = 4; 00049 //msg1.data[4] = 5; 00050 //msg1.data[5] = 6; 00051 //msg1.data[6] = 7; 00052 //msg1.data[7] = 8; 00053 00054 00055 msg2.id = 1338; 00056 msg2.len = 8;//length in bytes (1 to 8); 00057 msg2.data[0] = 100; // repeat for each byte. 00058 msg2.data[1] = 200; 00059 msg2.data[2] = 40; 00060 msg2.data[3] = 30; 00061 msg2.data[4] = 20; 00062 msg2.data[5] = 10; 00063 msg2.data[6] = 5; 00064 msg2.data[7] = 0; 00065 00066 00067 msg3.id = 1339; 00068 msg3.len = 8;//length in bytes (1 to 8); 00069 msg3.data[0] = 10; // repeat for each byte. 00070 msg3.data[1] = 20; 00071 msg3.data[2] = 10; 00072 msg3.data[3] = 20; 00073 msg3.data[4] = 10; 00074 msg3.data[5] = 20; 00075 msg3.data[6] = 10; 00076 msg3.data[7] = 20; 00077 00078 00079 00080 BT.printf("BT Inicio\n"); 00081 00082 while(1) { 00083 00084 for (int i = 1; i<=5; i++){ 00085 00086 msg1.data[0] = i; // repeat for each byte. 00087 msg1.data[1] = i+20; 00088 msg1.data[2] = i+40; 00089 msg1.data[3] = i+60; 00090 msg1.data[4] = i+80; 00091 msg1.data[5] = i+100; 00092 msg1.data[6] = i+120; 00093 msg1.data[7] = i+140; 00094 can1.write(msg1); 00095 wait_ms(1000); 00096 } 00097 00098 00099 // can1.write(msg2); 00100 00101 // can1.write(msg3); 00102 00103 BT.printf("BTMessage sent: %d\n", counter); 00104 00105 led1 = !led1; 00106 wait_ms(1000); 00107 00108 } 00109 }
Generated on Thu Oct 13 2022 00:30:09 by
1.7.2