VZTECH / Mbed 2 deprecated header_main

Dependencies:   EthernetInterface NTPClient mbed-rtos mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers parallelcpld.cpp Source File

parallelcpld.cpp

00001 #include "mbed.h"
00002 #include <stdint.h>
00003 #include "parallelcpld.h"
00004 #include "configs.h"
00005 #include "bits.h"
00006 
00007 uint8_t TXBuffer[DATA_SIZE];          // UART3 TX Buffer
00008 uint8_t tx_clear =1;
00009 
00010 void parallel_write( uint8_t data)                      // Print a variable using parallel protocol
00011 {   
00012         data0 = BIT0&(data);
00013         data1 = BIT1&(data);
00014         data2 = BIT2&(data);
00015         data3 = BIT3&(data);
00016         data4 = BIT4&(data);
00017         data5 = BIT5&(data);
00018         data6 = BIT6&(data);
00019         data7 = BIT7&(data);        
00020 }
00021 
00022 
00023 void send2callboxes(){                  // Needs: function parallel_write/ Global variables: TXBuffer, tx_clear / Configuration extern interrupt
00024         
00025         if ( tx_clear == 1)
00026         {   
00027             parallel_write( TXBuffer[0] );                  // Send the first position of TXBuffer first
00028             DataReady = 1;
00029                 
00030         }else
00031         {
00032             uart0_text("Error: Overflow Parallel Write TX");        // Error if the transmission is still in use
00033         }
00034     
00035 }
00036 
00037 
00038 //*****************************************************************************
00039 //                            EXTERN IRQ Handler
00040 //*****************************************************************************
00041 
00042 void get2(){   
00043     
00044     static uint16_t c = 1;       
00045     DataReady = 0;                              // Get Ready the new data
00046 //    led3 = !led3;
00047     tx_clear = 0;
00048 
00049     if ( c < 300 ) 
00050     {
00051         parallel_write ( TXBuffer[c] ) ;        // Write the next data to be send
00052         DataReady = 1;                          // Allow the data to be capture
00053         
00054     }else{
00055 //            led1 = 0;
00056 //            led2 = 0;
00057 //            led3 = 1;
00058 //            led4 = 1;
00059             tx_clear = 1;                       // Allow the next package to the transmitted
00060             c = 0;
00061         }
00062     c++;
00063 }