Renamed

Dependencies:   mbed

main.cpp

Committer:
ffxx68
Date:
2022-02-18
Revision:
1:9289febf4ae9
Parent:
0:07819bc70660
Child:
2:dff96be9617e

File content as of revision 1:9289febf4ae9:

#include "mbed.h" 
#include "send_pc1403.h"
#include "bin_file.h" // in-memory BIN file (until I integrate an SD-Card to store it...=
#include "bit_send.h"

Serial pc(USBTX,USBRX);
DigitalOut led(LED1);
Timer total_time;
DigitalIn    my_button(USER_BUTTON);


int main()
{

    int i, error;
    char inVal;
    FileInfo  info ; // PC bin-to-wav conversion information
    // flashing led on startup
    for (i=0; i<10; i+=1) {
        wait (0.1);
        led = !led;
    }
    // init vars
    led = 0;
     
    pc.baud(57600);

    // welcome message 
    pc.printf("\n\r ** MBED ** send to PC1403 ** \n\r");
    fflush(stdout);
    
    // main loop
    while(true) {
     
        pc.printf(" (push user button to send) \n\r");
        // wait for button pressed
        while ( my_button == 1 )
            wait ( .1 );
        
        total_time.reset();
        total_time.start();
    
        ///////////////////////////////////////////////
        // FILE SENDING
        // before a new bit stream to be sent
        bitHandlerInit();
        info.ident = IDENT_NEW_BAS;
        info.debug = 0x0040; // 0x0000 disable printf ;  0x0040 DEBUG
        error = FileSend ( bin_file_name, bin_file_bytes, BIN_FILE_SIZE, &info ) ; 
        pc.printf("FileSend error: %d \n\r", error);
        // stop consumer after last bit
        bitHandlerStop();
        // time for handler to complete
        while( bitHandlerRunning() ) 
            wait (.1); 
        ///////////////////////////////////////////////
       
        total_time.stop();
        pc.printf("DONE - time (ms): %d [send_err %d]\n\r", total_time.read_us()/1000, error);

        // doing nothing...
        wait(.1);              
    }
}