![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
voltando a versao de n aberturas e fechamentos de sockets data 19/09
Dependencies: EthernetInterface NTPClient mbed-rtos mbed EALib
Fork of header_main_publish by
configs.cpp@15:9c7456c1b6f4, 2014-09-18 (annotated)
- Committer:
- klauss
- Date:
- Thu Sep 18 13:56:13 2014 +0000
- Revision:
- 15:9c7456c1b6f4
- Parent:
- 0:4d17cd9c8f9d
- Child:
- 16:b45b5b7363d7
versao de ajuste pos teste de implantacao na pista
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
klauss | 0:4d17cd9c8f9d | 1 | #include "configs.h" |
klauss | 0:4d17cd9c8f9d | 2 | #include "mbed.h" |
klauss | 0:4d17cd9c8f9d | 3 | #include <stdint.h> |
klauss | 0:4d17cd9c8f9d | 4 | #include "UART3Interrupt.h" |
klauss | 0:4d17cd9c8f9d | 5 | #include "parallelcpld.h" |
klauss | 0:4d17cd9c8f9d | 6 | |
klauss | 0:4d17cd9c8f9d | 7 | //***************************************************************************** |
klauss | 0:4d17cd9c8f9d | 8 | // Pins/Modules Config |
klauss | 0:4d17cd9c8f9d | 9 | //***************************************************************************** |
klauss | 0:4d17cd9c8f9d | 10 | |
klauss | 0:4d17cd9c8f9d | 11 | DigitalOut led1(LED1); |
klauss | 0:4d17cd9c8f9d | 12 | DigitalOut led2(LED2); |
klauss | 0:4d17cd9c8f9d | 13 | DigitalOut led3(LED3); |
klauss | 0:4d17cd9c8f9d | 14 | DigitalOut led4(LED4); |
klauss | 0:4d17cd9c8f9d | 15 | |
klauss | 15:9c7456c1b6f4 | 16 | DigitalOut hack_led( p24 ); |
klauss | 15:9c7456c1b6f4 | 17 | |
klauss | 0:4d17cd9c8f9d | 18 | DigitalOut DataReady(p11); //IO 27 |
klauss | 0:4d17cd9c8f9d | 19 | |
klauss | 0:4d17cd9c8f9d | 20 | DigitalOut data0(p30); //LSB |
klauss | 0:4d17cd9c8f9d | 21 | DigitalOut data1(p31); |
klauss | 0:4d17cd9c8f9d | 22 | DigitalOut data2(p32); |
klauss | 0:4d17cd9c8f9d | 23 | DigitalOut data3(p33); |
klauss | 0:4d17cd9c8f9d | 24 | DigitalOut data4(p34); |
klauss | 0:4d17cd9c8f9d | 25 | DigitalOut data5(p37); |
klauss | 0:4d17cd9c8f9d | 26 | DigitalOut data6(p38); |
klauss | 0:4d17cd9c8f9d | 27 | DigitalOut data7(p39); //MSB |
klauss | 0:4d17cd9c8f9d | 28 | |
klauss | 0:4d17cd9c8f9d | 29 | InterruptIn NextData(p8); //IO 96 |
klauss | 0:4d17cd9c8f9d | 30 | InterruptIn FrameSync(p17); // GCLK1 |
klauss | 0:4d17cd9c8f9d | 31 | |
klauss | 0:4d17cd9c8f9d | 32 | //Ticker ticker; // Timer para Debug |
klauss | 0:4d17cd9c8f9d | 33 | |
klauss | 0:4d17cd9c8f9d | 34 | DigitalOut RST(p29); // Pino de reset para o CPLD |
klauss | 0:4d17cd9c8f9d | 35 | DigitalIn PPD(p25); // Pino de conexao com o cristal do CPLD |
klauss | 0:4d17cd9c8f9d | 36 | |
klauss | 0:4d17cd9c8f9d | 37 | DigitalOut ENABLE_F_REG(p18); // Configuracao da Alimentacao do CPLD |
klauss | 0:4d17cd9c8f9d | 38 | DigitalOut ENABLE_F_RX(p19); |
klauss | 0:4d17cd9c8f9d | 39 | DigitalOut ENABLE_F_TX(p20); |
klauss | 0:4d17cd9c8f9d | 40 | |
klauss | 0:4d17cd9c8f9d | 41 | Serial Uart3(p9,p10); // default baudrate = 9600; Sem paridade, 8bits, 1 stop-bit |
klauss | 0:4d17cd9c8f9d | 42 | Serial pc (USBTX,USBRX); |
klauss | 0:4d17cd9c8f9d | 43 | |
klauss | 0:4d17cd9c8f9d | 44 | void start_cpld( void ) { //CPLD Start |
klauss | 0:4d17cd9c8f9d | 45 | |
klauss | 0:4d17cd9c8f9d | 46 | static uint16_t reset = 10000; |
klauss | 0:4d17cd9c8f9d | 47 | ENABLE_F_REG = 1; |
klauss | 0:4d17cd9c8f9d | 48 | ENABLE_F_TX = 1; |
klauss | 0:4d17cd9c8f9d | 49 | ENABLE_F_RX = 1; |
klauss | 0:4d17cd9c8f9d | 50 | DataReady = 0; |
klauss | 0:4d17cd9c8f9d | 51 | RST = 1; |
klauss | 0:4d17cd9c8f9d | 52 | while(reset--){} |
klauss | 0:4d17cd9c8f9d | 53 | RST = 0; |
klauss | 0:4d17cd9c8f9d | 54 | } |
klauss | 0:4d17cd9c8f9d | 55 | |
klauss | 0:4d17cd9c8f9d | 56 | void config_lpc( void ) { // Configure LPC4088 |
klauss | 0:4d17cd9c8f9d | 57 | |
klauss | 0:4d17cd9c8f9d | 58 | Uart3.attach(&SerialRecvInterrupt, Uart3.RxIrq); // UART3_IRQ configuration |
klauss | 0:4d17cd9c8f9d | 59 | Uart3.format(8,SerialBase::Forced1,1); // UART3 mode configuration |
klauss | 0:4d17cd9c8f9d | 60 | Uart3.baud(2000000); |
klauss | 0:4d17cd9c8f9d | 61 | NVIC_SetPriority(UART3_IRQn,1); |
klauss | 0:4d17cd9c8f9d | 62 | pc.baud(115200); // USART to PC USB USART |
klauss | 0:4d17cd9c8f9d | 63 | NextData.rise(&get2); // Extern Pin Interrupt |
klauss | 0:4d17cd9c8f9d | 64 | FrameSync.rise(&RXFrameSync); // FrameSync for RX - Interrupt |
klauss | 0:4d17cd9c8f9d | 65 | __enable_irq(); |
klauss | 0:4d17cd9c8f9d | 66 | //ticker.attach(&timer,0.01); // Timer para Debug |
klauss | 0:4d17cd9c8f9d | 67 | } |
klauss | 0:4d17cd9c8f9d | 68 | |
klauss | 0:4d17cd9c8f9d | 69 | static uint8_t itoh[16]; |
klauss | 0:4d17cd9c8f9d | 70 | static uint8_t hexbuf[10]; |
klauss | 0:4d17cd9c8f9d | 71 | |
klauss | 0:4d17cd9c8f9d | 72 | uint8_t *hextoascii ( uint8_t src ) { |
klauss | 0:4d17cd9c8f9d | 73 | |
klauss | 0:4d17cd9c8f9d | 74 | hexbuf[0] = itoh[(src>>4) & 0x0f]; |
klauss | 0:4d17cd9c8f9d | 75 | hexbuf[1] = itoh[src & 0x0f]; |
klauss | 0:4d17cd9c8f9d | 76 | hexbuf[2] = 0; |
klauss | 0:4d17cd9c8f9d | 77 | return hexbuf; |
klauss | 0:4d17cd9c8f9d | 78 | |
klauss | 0:4d17cd9c8f9d | 79 | } |
klauss | 0:4d17cd9c8f9d | 80 | |
klauss | 0:4d17cd9c8f9d | 81 | void uart3_puts(uint8_t *src, uint16_t size){ // Print a string in UART3 |
klauss | 0:4d17cd9c8f9d | 82 | while (size--){ |
klauss | 0:4d17cd9c8f9d | 83 | while ( !(LPC_UART3->LSR &= (1<<5)) ) {} |
klauss | 0:4d17cd9c8f9d | 84 | LPC_UART3->THR = *src++; |
klauss | 0:4d17cd9c8f9d | 85 | } |
klauss | 0:4d17cd9c8f9d | 86 | } |
klauss | 0:4d17cd9c8f9d | 87 | |
klauss | 0:4d17cd9c8f9d | 88 | void uart0_puts( uint8_t *src) { // Print a string in UART3 |
klauss | 0:4d17cd9c8f9d | 89 | |
klauss | 0:4d17cd9c8f9d | 90 | uint16_t size = 300; |
klauss | 0:4d17cd9c8f9d | 91 | |
klauss | 0:4d17cd9c8f9d | 92 | while (size--){ |
klauss | 0:4d17cd9c8f9d | 93 | while ( !(LPC_UART0->LSR & (1<<5)) ) {} |
klauss | 0:4d17cd9c8f9d | 94 | LPC_UART0->THR = *src++; |
klauss | 0:4d17cd9c8f9d | 95 | } |
klauss | 0:4d17cd9c8f9d | 96 | } |
klauss | 0:4d17cd9c8f9d | 97 | |
klauss | 0:4d17cd9c8f9d | 98 | void uart0_putsx(volatile uint8_t *src ){ // Print a string in UART0 |
klauss | 0:4d17cd9c8f9d | 99 | uint16_t size = 300;//sizeof( src ); |
klauss | 0:4d17cd9c8f9d | 100 | uint8_t *buff; |
klauss | 0:4d17cd9c8f9d | 101 | while (size--) |
klauss | 0:4d17cd9c8f9d | 102 | { |
klauss | 0:4d17cd9c8f9d | 103 | buff = hextoascii(*(src++)); |
klauss | 0:4d17cd9c8f9d | 104 | for ( uint8_t i = 0; i < 3; i++ ){ |
klauss | 0:4d17cd9c8f9d | 105 | while ( !(LPC_UART0->LSR &= (1<<5)) ) {} |
klauss | 0:4d17cd9c8f9d | 106 | LPC_UART0->THR = buff[i]; //*src++; |
klauss | 0:4d17cd9c8f9d | 107 | } |
klauss | 0:4d17cd9c8f9d | 108 | } |
klauss | 0:4d17cd9c8f9d | 109 | } |
klauss | 0:4d17cd9c8f9d | 110 | |
klauss | 0:4d17cd9c8f9d | 111 | void uart0_text( const char* src){ // Print a string of constant in UART0 |
klauss | 0:4d17cd9c8f9d | 112 | static uint16_t size; |
klauss | 0:4d17cd9c8f9d | 113 | size = sizeof (src); |
klauss | 0:4d17cd9c8f9d | 114 | while (size--){ |
klauss | 0:4d17cd9c8f9d | 115 | while ( !(LPC_UART0->LSR &= (1<<5)) ) {} |
klauss | 0:4d17cd9c8f9d | 116 | LPC_UART0->THR = *src++; |
klauss | 0:4d17cd9c8f9d | 117 | } |
klauss | 0:4d17cd9c8f9d | 118 | } |
klauss | 0:4d17cd9c8f9d | 119 | |
klauss | 0:4d17cd9c8f9d | 120 | void xstrcpy(uint8_t * dest, const uint8_t * src) { |
klauss | 0:4d17cd9c8f9d | 121 | while (*src) *dest++ = *src++; |
klauss | 0:4d17cd9c8f9d | 122 | *dest = 0; |
klauss | 0:4d17cd9c8f9d | 123 | } |
klauss | 0:4d17cd9c8f9d | 124 | |
klauss | 0:4d17cd9c8f9d | 125 | void xmemcpy(uint8_t * dest, uint8_t * src, uint16_t size){ |
klauss | 0:4d17cd9c8f9d | 126 | while (size--) *dest++ = *src++; |
klauss | 0:4d17cd9c8f9d | 127 | } |