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.
Fork of MainBoard2018_Auto_Master_A_new by
Diff: Communication/RS485/RS485.cpp
- Revision:
- 0:669ef71cba68
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Communication/RS485/RS485.cpp Sat Sep 08 06:05:22 2018 +0000 @@ -0,0 +1,32 @@ +#include "RS485.h" +#include "mbed.h" +#include "ActuatorHub/ActuatorHub.h" +#include "../../LED/LED.h" +#include "../../System/Using.h" + +namespace RS485 { + DigitalOut selectBit(SELECTBIT_PIN); + Serial RS485Uart(RS485UART_TX, RS485UART_RX); + + void Transmit(); + + void RS485::Initialize() { + selectBit = 1; //送信固定 + RS485Uart.baud(38400); + RS485Uart.attach(Transmit, Serial::TxIrq); + } + + void Transmit() { + static uint8_t count = 0; + __disable_irq(); + RS485Uart.putc(RS485SendBuffer.GetData()); + if(count >= 200) { + #ifdef USE_MOTOR + LED_DEBUG2 = !LED_DEBUG2; + #endif + + count = 0; + } else count++; + __enable_irq(); + } +}