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 Mu.cpp Source File

Mu.cpp

00001 #include "Mu.h"
00002 #include "mbed.h"
00003 
00004 namespace MU {
00005     Serial MuUart(MU_TX, MU_RX);
00006 
00007     namespace {
00008         char Group[][4]     = {"01", "02", "03", "04"};
00009         char Channel[][4]   = {"08", "14", "1F", "2E"};
00010         char DI[][4]        = {"10", "20", "40", "80"};
00011         char EI[][4]        = {"01", "02", "04", "08"};
00012     }
00013 
00014     void Mu::SendCommand(char *command, char *value, uint8_t valueLength) {
00015         MuUart.putc('@');
00016         MuUart.putc(command[0]);
00017         MuUart.putc(command[1]);
00018         while(valueLength--) {
00019             MuUart.putc(*value);
00020             value++;
00021         }
00022         MuUart.putc('\r');
00023         MuUart.putc('\n');
00024     }
00025 
00026     void Mu::Initialize(uint8_t select) {
00027         MuUart.baud(19200);
00028 
00029         Mu::SendCommand("GI",Group[select],2);
00030         Mu::SendCommand("CH",Channel[select],2);
00031         Mu::SendCommand("DI",DI[select],2);
00032         Mu::SendCommand("EI",EI[select],2);
00033     }
00034 }