大季 矢花
/
MB2019_main_alltimes
aa
Communication/RS485/RS485.cpp
- Committer:
- M_souta
- Date:
- 2019-08-27
- Revision:
- 20:eae8c84f318c
- Parent:
- 0:669ef71cba68
- Child:
- 21:e3b58d675c1c
File content as of revision 20:eae8c84f318c:
#include "RS485.h" #include "mbed.h" #include "ActuatorHub/ActuatorHub.h" #include "../../LED/LED.h" #include "../../System/Using.h" namespace RS485 { DigitalOut selectBitT(SELECTBIT_T_PIN); DigitalOut selectBitR(SELECTBIT_R_PIN); Serial RS485Uart(RS485UART_TX, RS485UART_RX); Serial RS485Line(RS485LINE_TX, RS485LINE_RX); void Transmit(); void Recieve(); void RS485::Initialize() { selectBitT = 1; //送信固定 selectBitR = 0; //受信固定 RS485Uart.baud(38400); RS485Uart.attach(Transmit, Serial::TxIrq); //送信割り込み RS485Line.baud(38400); RS485Line.attach(Recieve, Serial::RxIrq); //受信割り込み } void Transmit() { __disable_irq(); static uint8_t count = 0; RS485Uart.putc(RS485SendBuffer.GetData()); if(count >= 200) { #ifdef USE_MOTOR LED_DEBUG2 = !LED_DEBUG2; #endif count = 0; } else count++; __enable_irq(); } void Recieve() { static uint8_t count = 0; __disable_irq(); char data = RS485Line.getc(); if(count >= 200) { LED_DEBUG1 = !LED_DEBUG1; count = 0; } else count++; __enable_irq(); } }