DA14580 Bluetooth Smart IC writer library
Dependents: 11u35_usbLocalFilesystem
Diff: DA14580.cpp
- Revision:
- 9:e2e84de053fc
- Parent:
- 8:af5210dbfe64
--- a/DA14580.cpp Thu Jul 07 01:26:52 2016 +0000 +++ b/DA14580.cpp Fri Aug 12 06:34:58 2016 +0000 @@ -1,7 +1,6 @@ /* @file DA14580.cpp */ -//#include "mbed.h" #include "DA14580.h" #include "loader.h" @@ -25,7 +24,8 @@ { _reset.write(_RESET); - _loadersize = sizeof(loader)/sizeof(loader[0]); +// _loadersize = sizeof(loader)/sizeof(loader[0]); + _loadersize = 0; _crc = 0x00; _recieve = 0; _read = 0; @@ -35,19 +35,21 @@ _status = SUCCESS; } -int DA14580::load() +int DA14580::load(char *filename) { _reset.write(_RESET); _status = SUCCESS; -/* - _fp = fopen(TARGET_FILE, "r" ); + + _fp = fopen(filename, "rb" ); if (_fp) { - _filesize = file_size(_fp); + _loadersize = file_size(_fp); + } else if( (!_fp) && (filename == LOADER_FILE) ){ + _fp = (FILE*) loader; } else { _status = E_FILE_NOT_FOUND; } -*/ + if(_status == SUCCESS) { _reset.write(_BOOT); wait_us(1); @@ -75,7 +77,7 @@ if(_status == SUCCESS) { for(int i = 0; i < _loadersize; i++) { - _read = loader[i]; + _read = getc(_fp); _ble.putc(_read); _crc = _crc ^ _read; } @@ -91,13 +93,13 @@ } } } -/* + fclose(_fp); #if defined(__MICROLIB) && defined(__ARMCC_VERSION) // with microlib and ARM compiler #warning "free(_fp)" free(_fp); #endif -*/ + return _status; }