DA14580 Bluetooth Smart IC writer library

Dependents:   11u35_usbLocalFilesystem

Revision:
6:db0ae78150a3
Parent:
5:45e9f3723a08
Child:
7:5f0fe36be5b3
--- a/DA14580.cpp	Tue Nov 10 01:12:06 2015 +0000
+++ b/DA14580.cpp	Fri Mar 04 10:33:45 2016 +0000
@@ -1,4 +1,4 @@
-/**
+/*
 @file DA14580.cpp
 */
 //#include "mbed.h"
@@ -36,12 +36,7 @@
 {
 
     _status = SUCCESS;
-    /*
-        while( _ble.readable() ) {
-            _recieve = _ble.getc();
-        }
-    */
-    _fp = fopen( LOADER_FILE, "rb" );
+    _fp = fopen(TARGET_FILE, "rb" );
     if (_fp) {
         _filesize = file_size(_fp);
     } else {
@@ -51,30 +46,18 @@
         _reset.write(_BOOT);
         wait_us(1);
         while(1) {
-//            if( _ble.readable() ) {
             while( _ble.readable() ) {
                 _recieve = _ble.getc();
             }
-            wait_us(150); //DEBUG
             if(_recieve == STX) {
                 _ble.putc(SOH);
-                wait_us(150); //DEBUG
                 _ble.putc(_filesize & 0xff);
-                wait_us(150); //DEBUG
                 _ble.putc( (_filesize >> 8) & 0xff);
-                wait_us(150); //DEBUG
-                _reset.write(_RESET); //DEBUG
-                _reset.write(_BOOT); //DEBUG
-                _reset.write(_RESET); //DEBUG
                 break;
             }
-//            }
         }
 
-//        _ble.putc(_filesize & 0xff);
-//        _ble.putc( (_filesize >> 8) & 0xff);
         while(1) {
-//            if( _ble.readable() ) {
             _recieve = _ble.getc();
             if(_recieve == ACK) {
                 break;
@@ -82,7 +65,6 @@
                 _status = E_ACK_NOT_RETURNED;
                 break;
             }
-//            }
         }
 
         if(_status == SUCCESS) {
@@ -90,20 +72,16 @@
                 _read = getc(_fp);
                 _ble.putc(_read);
                 _crc = _crc ^ _read;
-                wait_us(150); //DEBUG
             }
             while(1) {
-//                if( _ble.readable() ) {
                 _recieve = _ble.getc();
                 if(_recieve == _crc) {
                     _ble.putc(ACK);
-                    wait_us(150); //DEBUG
                     break;
                 } else {
                     _status = E_CRC_MISMATCH;
                     break;
                 }
-//                }
             }
         }
     }
@@ -114,7 +92,6 @@
 #endif
     return _status;
 
-
 }
 
 int DA14580::file_size( FILE *fp )