mbed-src updated for BMD-200 evaluation board. Just pin numbers are updated.
Dependents: mbed_blinky-bmd-200 bmd-200_accel_demo firstRig
Fork of mbed-src by
Replacement for the "mbed" or "mbed-src" library when using the BMD-200 Evaluation kit. This library only remaps the pin names (i.e. LED1 points to p0.01 instead of p0.18, etc) as used by the BMD-200 Evaluation board (select the nRF51822_mkit platform). All other code is untouched.
Diff: common/retarget.cpp
- Revision:
- 432:255afbe6270c
- Parent:
- 285:31249416b6f9
- Child:
- 476:44b5a0bc6da6
diff -r d406b7919023 -r 255afbe6270c common/retarget.cpp --- a/common/retarget.cpp Tue Dec 09 14:30:09 2014 +0000 +++ b/common/retarget.cpp Tue Dec 09 14:45:08 2014 +0000 @@ -480,3 +480,55 @@ return (caddr_t) prev_heap; } #endif + + +namespace mbed { + +void mbed_set_unbuffered_stream(FILE *_file) { +#if defined (__ICCARM__) + char buf[2]; + std::setvbuf(_file,buf,_IONBF,NULL); +#else + setbuf(_file, NULL); +#endif +} + +int mbed_getc(FILE *_file){ +#if defined (__ICCARM__) + /*This is only valid for unbuffered streams*/ + int res = std::fgetc(_file); + if (res>=0){ + _file->_Mode = (unsigned short)(_file->_Mode & ~ 0x1000);/* Unset read mode */ + _file->_Rend = _file->_Wend; + _file->_Next = _file->_Wend; + } + return res; +#else + return std::fgetc(_file); +#endif +} + +char* mbed_gets(char*s, int size, FILE *_file){ +#if defined (__ICCARM__) + /*This is only valid for unbuffered streams*/ + char *str = fgets(s,size,_file); + if (str!=NULL){ + _file->_Mode = (unsigned short)(_file->_Mode & ~ 0x1000);/* Unset read mode */ + _file->_Rend = _file->_Wend; + _file->_Next = _file->_Wend; + } + return str; +#else + return std::fgets(s,size,_file); +#endif +} + +} // namespace mbed + + + + + + + +