Modularizando o src

Dependencies:   EALib EthernetInterface_vz mbed-rtos mbed

Fork of header_main_colinas_V0-20-09-14 by VZTECH

configs.cpp

Committer:
klauss
Date:
2015-05-11
Revision:
122:480c44b0e205
Parent:
121:ee02790d00b7
Child:
135:2f4290590e51

File content as of revision 122:480c44b0e205:

#include "configs.h"

//*****************************************************************************
//                             Pins/Modules Config
//***************************************************************************** 

InterruptIn NextData(p8);                   // IO 96
InterruptIn FrameSync(p17);                 // GCLK1

//Ticker ticker;                            // Timer para Debug

DigitalOut RST(p29);                        // Pino de reset para o CPLD
DigitalIn PPD(p25);                         // Pino de conexao com o cristal do CPLD

DigitalOut ENABLE_F_REG(p18);               // Configuracao da Alimentacao do CPLD
DigitalOut ENABLE_F_RX(p19);
DigitalOut ENABLE_F_TX(p20);

Serial  Uart3(p9,p10);  // default baudrate = 9600; Sem paridade, 8bits, 1 stop-bit 

int start_cpld( void ) {                        //CPLD Start
    static uint16_t reset = 10000;
    ENABLE_F_REG = 1;                                
    ENABLE_F_TX = 1;
    ENABLE_F_RX = 1;
    DataReady = 0;
    RST = 1;
    while( reset-- > 1 ){}
    RST = 0;
    return ( 0 );
}

///< Configure LPC4088
int config_lpc( void ){
    // UART3_IRQ configuration
    Uart3.attach(&SerialRecvInterrupt, Uart3.RxIrq);
    
    // UART3 mode configuration
    Uart3.format(8,SerialBase::Forced1,1);
    
    Uart3.baud(2000000);                                
    
    NVIC_SetPriority(UART3_IRQn,1);
    
    // USART to PC USB USART
    pc.baud(115200);
    
    // Extern Pin Interrupt
    NextData.rise(&get2);
    
    // FrameSync for RX - Interrupt
    FrameSync.rise(&RXFrameSync);
    
    __enable_irq();
    
    // iniciando o pin de controle do arduino
    hw_extern_wdt = 0;
    
    return ( 0 );
}

static uint8_t itoh[16];
static uint8_t hexbuf[10];

uint8_t *hextoascii ( uint8_t src ) {
  
  hexbuf[0] = itoh[(src>>4) & 0x0f];  
  hexbuf[1] = itoh[src & 0x0f];
  hexbuf[2] = 0;
  return hexbuf;
    
}

void uart3_puts(uint8_t *src, uint16_t size){         // Print a string in UART3
    while (size--){
        while ( !(LPC_UART3->LSR &= (1<<5)) ) {} 
        LPC_UART3->THR = *src++;
    }
}

void uart0_puts( uint8_t *src) {         // Print a string in UART3
  
   uint16_t size = 300;
    
    while (size--){
        while ( !(LPC_UART0->LSR & (1<<5)) ) {} 
        LPC_UART0->THR = *src++;
    }
}

void uart0_putsx(volatile uint8_t *src ){            // Print a string in UART0   
    uint16_t size = 300;//sizeof( src ); 
    uint8_t *buff;
    while (size--)
    {   
        buff = hextoascii(*(src++));
        for ( uint8_t i  = 0; i < 3; i++ ){
            while ( !(LPC_UART0->LSR &= (1<<5))  ) {} 
            LPC_UART0->THR = buff[i];           //*src++;
        }
    }
}

void uart0_text( const char* src){                      // Print a string of constant in UART0
    static uint16_t size;
    size = sizeof (src);
    while (size--){
        while ( !(LPC_UART0->LSR &= (1<<5))  ) {} 
        LPC_UART0->THR = *src++;   
    }
}