huhuh

Dependencies:   mbed QEI

Fork of MainBoard2018_Auto_Master_A by Taiki Maruyama

Communication/RS485/RS485.cpp

Committer:
7ka884
Date:
2018-10-01
Revision:
6:10e22bc327ce
Parent:
0:669ef71cba68

File content as of revision 6:10e22bc327ce:

#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();
    }
}