Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: EthernetInterface NTPClient mbed-rtos mbed
configs.cpp
00001 #include "configs.h" 00002 #include "mbed.h" 00003 #include <stdint.h> 00004 #include "UART3Interrupt.h" 00005 #include "parallelcpld.h" 00006 00007 //***************************************************************************** 00008 // Pins/Modules Config 00009 //***************************************************************************** 00010 00011 DigitalOut led1(LED1); 00012 DigitalOut led2(LED2); 00013 DigitalOut led3(LED3); 00014 DigitalOut led4(LED4); 00015 00016 DigitalOut DataReady(p11); //IO 27 00017 00018 DigitalOut data0(p30); //LSB 00019 DigitalOut data1(p31); 00020 DigitalOut data2(p32); 00021 DigitalOut data3(p33); 00022 DigitalOut data4(p34); 00023 DigitalOut data5(p37); 00024 DigitalOut data6(p38); 00025 DigitalOut data7(p39); //MSB 00026 00027 InterruptIn NextData(p8); //IO 96 00028 InterruptIn FrameSync(p17); // GCLK1 00029 00030 //Ticker ticker; // Timer para Debug 00031 00032 DigitalOut RST(p29); // Pino de reset para o CPLD 00033 DigitalIn PPD(p25); // Pino de conexao com o cristal do CPLD 00034 00035 DigitalOut ENABLE_F_REG(p18); // Configuracao da Alimentacao do CPLD 00036 DigitalOut ENABLE_F_RX(p19); 00037 DigitalOut ENABLE_F_TX(p20); 00038 00039 Serial Uart3(p9,p10); // default baudrate = 9600; Sem paridade, 8bits, 1 stop-bit 00040 Serial pc (USBTX,USBRX); 00041 00042 void start_cpld( void ) { //CPLD Start 00043 00044 static uint16_t reset = 10000; 00045 ENABLE_F_REG = 1; 00046 ENABLE_F_TX = 1; 00047 ENABLE_F_RX = 1; 00048 DataReady = 0; 00049 RST = 1; 00050 while(reset--){} 00051 RST = 0; 00052 } 00053 00054 void config_lpc( void ) { // Configure LPC4088 00055 00056 Uart3.attach(&SerialRecvInterrupt, Uart3.RxIrq); // UART3_IRQ configuration 00057 Uart3.format(8,SerialBase::Forced1,1); // UART3 mode configuration 00058 Uart3.baud(2000000); 00059 NVIC_SetPriority(UART3_IRQn,1); 00060 pc.baud(115200); // USART to PC USB USART 00061 NextData.rise(&get2); // Extern Pin Interrupt 00062 FrameSync.rise(&RXFrameSync); // FrameSync for RX - Interrupt 00063 __enable_irq(); 00064 //ticker.attach(&timer,0.01); // Timer para Debug 00065 } 00066 00067 static uint8_t itoh[16]; 00068 static uint8_t hexbuf[10]; 00069 00070 uint8_t *hextoascii ( uint8_t src ) { 00071 00072 hexbuf[0] = itoh[(src>>4) & 0x0f]; 00073 hexbuf[1] = itoh[src & 0x0f]; 00074 hexbuf[2] = 0; 00075 return hexbuf; 00076 00077 } 00078 00079 void uart3_puts(uint8_t *src, uint16_t size){ // Print a string in UART3 00080 while (size--){ 00081 while ( !(LPC_UART3->LSR &= (1<<5)) ) {} 00082 LPC_UART3->THR = *src++; 00083 } 00084 } 00085 00086 void uart0_puts( uint8_t *src) { // Print a string in UART3 00087 00088 uint16_t size = 300; 00089 00090 while (size--){ 00091 while ( !(LPC_UART0->LSR & (1<<5)) ) {} 00092 LPC_UART0->THR = *src++; 00093 } 00094 } 00095 00096 void uart0_putsx(volatile uint8_t *src ){ // Print a string in UART0 00097 uint16_t size = 300;//sizeof( src ); 00098 uint8_t *buff; 00099 while (size--) 00100 { 00101 buff = hextoascii(*(src++)); 00102 for ( uint8_t i = 0; i < 3; i++ ){ 00103 while ( !(LPC_UART0->LSR &= (1<<5)) ) {} 00104 LPC_UART0->THR = buff[i]; //*src++; 00105 } 00106 } 00107 } 00108 00109 void uart0_text( const char* src){ // Print a string of constant in UART0 00110 static uint16_t size; 00111 size = sizeof (src); 00112 while (size--){ 00113 while ( !(LPC_UART0->LSR &= (1<<5)) ) {} 00114 LPC_UART0->THR = *src++; 00115 } 00116 } 00117 00118 void xstrcpy(uint8_t * dest, const uint8_t * src) { 00119 while (*src) *dest++ = *src++; 00120 *dest = 0; 00121 } 00122 00123 void xmemcpy(uint8_t * dest, uint8_t * src, uint16_t size){ 00124 while (size--) *dest++ = *src++; 00125 }
Generated on Fri Jul 22 2022 09:19:18 by
1.7.2