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
Communication/RS485/RS485.cpp@14:dfcec98f5aa9, 2018-10-21 (annotated)
- Committer:
- kishibekairohan
- Date:
- Sun Oct 21 02:14:15 2018 +0000
- Revision:
- 14:dfcec98f5aa9
- Parent:
- 0:669ef71cba68
aaaaaa
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
t_yamamoto | 0:669ef71cba68 | 1 | #include "RS485.h" |
t_yamamoto | 0:669ef71cba68 | 2 | #include "mbed.h" |
t_yamamoto | 0:669ef71cba68 | 3 | #include "ActuatorHub/ActuatorHub.h" |
t_yamamoto | 0:669ef71cba68 | 4 | #include "../../LED/LED.h" |
t_yamamoto | 0:669ef71cba68 | 5 | #include "../../System/Using.h" |
t_yamamoto | 0:669ef71cba68 | 6 | |
t_yamamoto | 0:669ef71cba68 | 7 | namespace RS485 { |
t_yamamoto | 0:669ef71cba68 | 8 | DigitalOut selectBit(SELECTBIT_PIN); |
t_yamamoto | 0:669ef71cba68 | 9 | Serial RS485Uart(RS485UART_TX, RS485UART_RX); |
t_yamamoto | 0:669ef71cba68 | 10 | |
t_yamamoto | 0:669ef71cba68 | 11 | void Transmit(); |
t_yamamoto | 0:669ef71cba68 | 12 | |
t_yamamoto | 0:669ef71cba68 | 13 | void RS485::Initialize() { |
t_yamamoto | 0:669ef71cba68 | 14 | selectBit = 1; //送信固定 |
t_yamamoto | 0:669ef71cba68 | 15 | RS485Uart.baud(38400); |
t_yamamoto | 0:669ef71cba68 | 16 | RS485Uart.attach(Transmit, Serial::TxIrq); |
t_yamamoto | 0:669ef71cba68 | 17 | } |
t_yamamoto | 0:669ef71cba68 | 18 | |
t_yamamoto | 0:669ef71cba68 | 19 | void Transmit() { |
t_yamamoto | 0:669ef71cba68 | 20 | static uint8_t count = 0; |
t_yamamoto | 0:669ef71cba68 | 21 | __disable_irq(); |
t_yamamoto | 0:669ef71cba68 | 22 | RS485Uart.putc(RS485SendBuffer.GetData()); |
t_yamamoto | 0:669ef71cba68 | 23 | if(count >= 200) { |
t_yamamoto | 0:669ef71cba68 | 24 | #ifdef USE_MOTOR |
t_yamamoto | 0:669ef71cba68 | 25 | LED_DEBUG2 = !LED_DEBUG2; |
t_yamamoto | 0:669ef71cba68 | 26 | #endif |
t_yamamoto | 0:669ef71cba68 | 27 | |
t_yamamoto | 0:669ef71cba68 | 28 | count = 0; |
t_yamamoto | 0:669ef71cba68 | 29 | } else count++; |
t_yamamoto | 0:669ef71cba68 | 30 | __enable_irq(); |
t_yamamoto | 0:669ef71cba68 | 31 | } |
t_yamamoto | 0:669ef71cba68 | 32 | } |