aa

Dependencies:   mbed

Committer:
yabahiro
Date:
Thu Dec 12 07:16:20 2019 +0000
Revision:
60:24ebb611f26e
Parent:
1:b1219d8ca117
aa

Who changed what in which revision?

UserRevisionLine numberNew contents of line
t_yamamoto 0:669ef71cba68 1 #include "Mu.h"
7ka884 1:b1219d8ca117 2 #include "mbed.h"
t_yamamoto 0:669ef71cba68 3
t_yamamoto 0:669ef71cba68 4 namespace MU {
7ka884 1:b1219d8ca117 5 Serial MuUart(MU_TX, MU_RX);
t_yamamoto 0:669ef71cba68 6
t_yamamoto 0:669ef71cba68 7 namespace {
t_yamamoto 0:669ef71cba68 8 char Group[][4] = {"01", "02", "03", "04"};
t_yamamoto 0:669ef71cba68 9 char Channel[][4] = {"08", "14", "1F", "2E"};
t_yamamoto 0:669ef71cba68 10 char DI[][4] = {"10", "20", "40", "80"};
t_yamamoto 0:669ef71cba68 11 char EI[][4] = {"01", "02", "04", "08"};
t_yamamoto 0:669ef71cba68 12 }
t_yamamoto 0:669ef71cba68 13
t_yamamoto 0:669ef71cba68 14 void Mu::SendCommand(char *command, char *value, uint8_t valueLength) {
t_yamamoto 0:669ef71cba68 15 MuUart.putc('@');
t_yamamoto 0:669ef71cba68 16 MuUart.putc(command[0]);
t_yamamoto 0:669ef71cba68 17 MuUart.putc(command[1]);
t_yamamoto 0:669ef71cba68 18 while(valueLength--) {
t_yamamoto 0:669ef71cba68 19 MuUart.putc(*value);
t_yamamoto 0:669ef71cba68 20 value++;
t_yamamoto 0:669ef71cba68 21 }
t_yamamoto 0:669ef71cba68 22 MuUart.putc('\r');
t_yamamoto 0:669ef71cba68 23 MuUart.putc('\n');
t_yamamoto 0:669ef71cba68 24 }
t_yamamoto 0:669ef71cba68 25
t_yamamoto 0:669ef71cba68 26 void Mu::Initialize(uint8_t select) {
t_yamamoto 0:669ef71cba68 27 MuUart.baud(19200);
t_yamamoto 0:669ef71cba68 28
t_yamamoto 0:669ef71cba68 29 Mu::SendCommand("GI",Group[select],2);
t_yamamoto 0:669ef71cba68 30 Mu::SendCommand("CH",Channel[select],2);
t_yamamoto 0:669ef71cba68 31 Mu::SendCommand("DI",DI[select],2);
t_yamamoto 0:669ef71cba68 32 Mu::SendCommand("EI",EI[select],2);
t_yamamoto 0:669ef71cba68 33 }
t_yamamoto 0:669ef71cba68 34 }