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: mbed SDFileSystemFilinfo AriSnProtocol NetServicesMin AriSnComm MODSERIAL PowerControlClkPatch DS1820OW
Diff: SnCommUsb.cpp
- Revision:
- 16:744ce85aede2
- Parent:
- 13:7a1fb885a8e4
- Child:
- 18:55f1581f2ee4
diff -r f2569d8e4176 -r 744ce85aede2 SnCommUsb.cpp
--- a/SnCommUsb.cpp Fri Aug 31 02:09:09 2012 +0000
+++ b/SnCommUsb.cpp Wed Sep 12 04:47:22 2012 +0000
@@ -12,34 +12,29 @@
#define CALL_MEMBER_FN(object,ptrToMember) ((object).*(ptrToMember))
-AjK::MODSERIAL* SnCommUsb::fgCpu = 0;
+SN_USB_SERIAL* SnCommUsb::fgCpu = 0;
static const uint8_t __kMaxUChar = ~0;
-#ifdef LED_ON_RECV
-void __Recv(MODSERIAL_IRQ_INFO* s) {
- static DigitalOut led4(LED4);
- static DigitalOut led3(LED3);
- for (uint8_t i=0; i<10; i++) {
- led4=!led4;
- led3=!led3;
- wait(0.1);
- }
-}
-#endif
-
-SnCommWin::ECommWinResult SnCommUsb::SetupPort(AjK::MODSERIAL& cpu) {
- fgCpu = &cpu;
+SnCommWin::ECommWinResult SnCommUsb::SetupPort(SN_USB_SERIAL* cpu) {
+ fgCpu = cpu;
// set up serial-usb port
- fgCpu->baud( 230400 );
- fgCpu->format( 8, Serial::None, 1 );
- fgCpu->txBufferFlush();
- fgCpu->rxBufferFlush();
-#ifdef LED_ON_RECV
- fgCpu->attach(&__Recv, MODSERIAL::RxIrq);
+ if (fgCpu!=0) {
+ //fgCpu->baud( 230400 );
+ fgCpu->baud( 115200 );
+ fgCpu->format( 8, Serial::None, 1 );
+#ifdef USE_MODSERIAL
+ fgCpu->txBufferFlush();
+ fgCpu->rxBufferFlush();
#endif
- return kOkNoMsg;
+ while ( fgCpu->readable() ) {
+ fgCpu->getc();
+ }
+ return kOkNoMsg;
+ } else {
+ return kCanNotConnect;
+ }
}
int SnCommUsb::GetC(char* const d) {
@@ -89,17 +84,17 @@
}
Watchdog::kick(); // don't reset; wait until timeout
}
- return res; // timeout
+ return b; // timeout
}
int32_t SnCommUsb::ReceiveAll(char* const buf, const uint32_t mlen,
const uint32_t timeout_clock) {
- return DoIO(buf, mlen, timeout_clock, &AjK::MODSERIAL::readable, &SnCommUsb::GetC);
+ return DoIO(buf, mlen, timeout_clock, &SN_USB_SERIAL::readable, &SnCommUsb::GetC);
}
int32_t SnCommUsb::SendAll(char* const data, const uint32_t length,
const uint32_t timeout_clock) {
- return DoIO(data, length, timeout_clock, &AjK::MODSERIAL::writeable, &SnCommUsb::PutC);
+ return DoIO(data, length, timeout_clock, &SN_USB_SERIAL::writeable, &SnCommUsb::PutC);
}