aaaaaaaaa

Dependencies:   QEI mbed

Fork of MainBoard2018_Auto_Master_A_new by Akihiro Nakabayashi

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers RS485.cpp Source File

RS485.cpp

00001 #include "RS485.h"
00002 #include "mbed.h"
00003 #include "ActuatorHub/ActuatorHub.h"
00004 #include "../../LED/LED.h"
00005 #include "../../System/Using.h"
00006 
00007 namespace RS485 {
00008     DigitalOut selectBit(SELECTBIT_PIN);
00009     Serial RS485Uart(RS485UART_TX, RS485UART_RX);
00010 
00011     void Transmit();
00012 
00013     void RS485::Initialize() {
00014         selectBit = 1;  //送信固定
00015         RS485Uart.baud(38400);
00016         RS485Uart.attach(Transmit, Serial::TxIrq);
00017     }
00018 
00019     void Transmit() {
00020         static uint8_t count = 0;
00021         __disable_irq();
00022         RS485Uart.putc(RS485SendBuffer.GetData());
00023         if(count >= 200) {
00024             #ifdef USE_MOTOR
00025             LED_DEBUG2 = !LED_DEBUG2;
00026             #endif
00027 
00028             count = 0;
00029         } else count++;
00030         __enable_irq();
00031     }
00032 }