#include #include #include "CIF.h" #include "fft.h" #include "timer_counter.h" #include "pio_control.h" #include #include #include //include #define PS_BASE 0xFFFF4000 #define PS_PCER 0x04 #define PS_PCDR 0x04 /* now declare (and allocate space for) some kernel objects, like the two threads we will use */ cyg_thread thread_s[2]; /* space for two thread objects */ static cyg_interrupt intTC0; static cyg_handle_t intTC0_handle; static cyg_sem_t TC0_data_ready; static cyg_sem_t TC0_transmitir; static cyg_sem_t TC0_fin_transmision; cyg_count32 TC0_data_ready_counter; cyg_count32 TC0_transmitir_counter; cyg_count32 TC0_fin_transmision_counter; #define CYGNUM_HAL_PRI_HIGH 0 cyg_uint16 TC0_TALTO; cyg_uint16 TC0_PERIODO; char stack[2][4096]; /* space for two 4K stacks */ #define TC0_MAX_DATA 2048 #define TC0_NDAT 5 cyg_uint16 TC0_RAM[TC0_MAX_DATA]; /*Espacio para 2048 datos de 16bits para el canal0*/ cyg_uint16 TC0_RBM[TC0_MAX_DATA]; /*8K en total */ cyg_uint16 TC0_CUENTA1=0; cyg_uint16 TC0_CUENTA2=0; /* now the handles for the threads */ cyg_handle_t main_thread; cyg_handle_t instrumentation_thread; /* and now variables for the procedure which is the thread */ cyg_thread_entry_t main_program; cyg_thread_entry_t instrumentation_program; /* and now a mutex to protect calls to the C library */ cyg_mutex_t cliblock; cyg_vector_t intTC0_vector = TC0_IRQ; cyg_uint32 interrupt_TC0_isr( cyg_vector_t vector, cyg_addrword_t data) //BASADO EN eCos book, pag 48 { cyg_interrupt_mask(vector); cyg_interrupt_acknowledge(vector); return(CYG_ISR_HANDLED | CYG_ISR_CALL_DSR); } void interrupt_TC0_dsr( cyg_vector_t vector, cyg_ucount32 count, cyg_addrword_t data) { HAL_IO_REGISTER REGISTER; cyg_semaphore_post(&TC0_data_ready); REGISTER=TC_BASE+TC_CHANNEL0+TC_RA; HAL_READ_UINT16(REGISTER,TC0_PERIODO); REGISTER=TC_BASE+TC_CHANNEL0+TC_RB; HAL_READ_UINT16(REGISTER,TC0_TALTO); cyg_interrupt_unmask(vector); } void cyg_user_start(void) { HAL_IO_REGISTER REGISTER; cyg_uint32 TC_REGISTER; printf(STR_HEADER); cyg_priority_t intTC0_priority = CYGNUM_HAL_PRI_HIGH; printf("Iniciando la configuración del TC,Medición PWM"); //Hay que activar el periferico TC_REGISTER=0x00; TC_REGISTER=TC_REGISTER | (PIO_PER_ENABLE<