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.
Dependencies: Adafruit-PWM-Servo-Driver MPU6050 RS300 mbed
SCI.cpp
- Committer:
- syundo0730
- Date:
- 2013-02-03
- Revision:
- 12:6cd135bf03bd
- Child:
- 13:711f74b2fa33
File content as of revision 12:6cd135bf03bd:
#include "mbed.h"
#include "SCI.h"
SCI::SCI(PinName tx, PinName rx)
{
serial = new Serial(tx, rx);
}
SCI::~SCI()
{
delete serial;
}
char SCI::getid()
{
char comm, id;
comm = getc_nowait();
if (comm == 'A') {
serial->putc(comm);
serial->printf("command");
id = getc_wait();
}
return id;
}
char SCI::getc_wait()
{
while (!serial->readable()) {
serial->printf("waiting..");
}
return serial->getc();
}
char SCI::getc_nowait()
{
uint8_t buf = 0;
if (serial->readable()) {
buf = serial->getc();
}
return buf;
}
/*uint16_t readint(void)
{
uint8_t buff[16];
buff[0] = pc->getc();
buff[1] = pc->getc();
uint16_t val;
val = (uint16_t)(buff[1] << 8) | (uint16_t)buff[0];
return val;
}
void sendint(uint16_t val)
{
uint8_t buff[16];
buff[0] = (uint8_t)(val & 0x00FF);
buff[1] = (uint8_t)(val >> 8);
pc.putc(buff[0]);
pc.putc(buff[1]);
}*/