uint8 bu_start(CB_LIST *buffer) { uint8 result = BU_BAD_ARGUMENT; if (buffer != NULL) { if (_buffer == NULL) { _buffer = buffer; isr_1_StartEx(bu_interrupt); isr_1_ClearPending(); /* * This delay gives the button pins time to go high. */ CyDelay(10); result = BU_SUCCESS; } else { result = BU_FAILURE; } } return result; }
int main() { // Enable global interrupts CyGlobalIntEnable; // Enable bootloader button // (need to clear pending interrupt first) isr_1_ClearPending(); isr_1_StartEx(isr_bootloader); // Enable analog multiplexer (chooses thermocouple input) AMux_1_Start(); // Enable op-amp (amplifies thermocouple signal) Opamp_1_Start(); // Enable ADC (reads amplified signal) ADC_SAR_Seq_1_Start(); ADC_SAR_Seq_1_StartConvert(); // Enable serial transmission UART_1_Start(); // To avoid a flash on power-on, the relay pin is configured as a // high impedance input initially // Because some guy on the internet says so: // http://www.cypress.com/forum/psoc-4-architecture/low-initial-drive-state-pwm-components Pin_Relays_Write(1); // HIGH to turn PNP transistor OFF Pin_Relays_SetDriveMode(Pin_Relays_DM_STRONG); for(;;) { // Read thermocouples and send over serial // Note that externally (and over serial communication), // 0 is T1, 1 is T2, and 2 is T3 SendTemperature(0, ADC_OFFSET_0, OPAMP_GAIN_FACTOR_0); SendTemperature(1, ADC_OFFSET_1, OPAMP_GAIN_FACTOR_1); SendTemperature(2, ADC_OFFSET_2, OPAMP_GAIN_FACTOR_2); // Newline for easier debugging UART_1_UartPutString("\r\n"); // Wait a bit, processing serial command input in between delays uint8 i; for (i = 0; i < 5; i++) { ReadSerialInput(); CyDelay(100); } // Safety feature: Ensure that the relays do not stay on for more than // ~30 seconds without communication from the serial control program if (relayState) { if (++relayOnCycles >= 60) { UART_1_UartPutString("R=0 (inactivity)\r\n"); SetRelays(0); } } else { relayOnCycles = 0; } } }
void main(){ UART_1_Start(); /* choose when we receive interrupts from tx and rx */ UART_1_SetTxInterruptMode(UART_1_TX_STS_COMPLETE); UART_1_SetRxInterruptMode(UART_1_RX_STS_FIFO_NOTEMPTY); CyGlobalIntEnable; UART_1_ClearTxBuffer(); UART_1_ClearRxBuffer(); LCD_Char_1_Start(); LCD_Char_1_Position(0,0); /* initialize our source data to index */ int j; for(j = 0; j < DATA_SIZE; ++j){ sourceData[j] = j; } /* enable our interrupt routines */ isr_1_StartEx(tx_int); isr_2_StartEx(rx_int); /* idle loop until we finish our transmission */ while(!rx_done){} int k; int errors = 0; /* data validation */ for(k = 0; k < DATA_SIZE; ++k) if(sourceData[k] != receiveData[k]) ++errors; /* print errors to lcd */ LCD_Char_1_PrintString("errors: "); LCD_Char_1_PrintNumber(errors); LCD_Char_1_Position(1,0); LCD_Char_1_PrintString("tx:"); LCD_Char_1_PrintNumber(tx_cnt); LCD_Char_1_PrintString(" rx:"); LCD_Char_1_PrintNumber(rx_cnt); for(;;){ } }
int main() { CyGlobalIntEnable; /* Uncomment this line to enable global interrupts. */ isr_1_StartEx(nunchuck_isr); VDAC_Start(); I2C_1_Start(); SendHandshake(); for(;;) { GetDataFromNunChuck(); CyDelay(1); int test = GetJoystickY(); VDAC_SetValue(test + 126); } }
void sonido(uint8 ld) { SDown_Write(1); CyDelay(250); if(ld==1){ isr_1_StartEx(Interrupcion_1); Timer_1_Start(); VDAC8_1_Start(); i1=0; NextSample_1=0; } else{ isr_2_StartEx(Interrupcion_2); Timer_2_Start(); VDAC8_2_Start(); i2=0; NextSample_2=0; } }
/*main*/ void main(void) { /*Preliminary parts not important*/ LCD_Char_1_Start(); ADC_DelSig_1_Start(); ADC_DelSig_1_StartConvert(); Configure_DMA(); isr_1_StartEx(Buffer_complete); isr_2_StartEx(LPF_buffer_complete); ADC_DelSig_1_SetCoherency(ADC_DelSig_1_COHER_MID); Filter_SetDalign(Filter_STAGEA_DALIGN,Filter_ENABLED); Filter_SetDalign(Filter_HOLDA_DALIGN,Filter_ENABLED); Filter_SetCoherency(Filter_STAGEA_COHER,Filter_KEY_MID); Filter_SetCoherency(Filter_HOLDA_COHER,Filter_KEY_MID); Filter_SetCoherency(Filter_CHANNEL_A,Filter_KEY_MID); Filter_SetDalign(Filter_STAGEB_DALIGN,Filter_ENABLED); Filter_SetDalign(Filter_HOLDB_DALIGN,Filter_ENABLED); Filter_SetCoherency(Filter_STAGEB_COHER,Filter_KEY_MID); Filter_SetCoherency(Filter_HOLDB_COHER,Filter_KEY_MID); Filter_SetCoherency(Filter_CHANNEL_B,Filter_KEY_MID); CyGlobalIntEnable; Filter_Start(); /*Writes ADC values to ADC_samples array*/ while(1){ if (isr_BC_flag==1){ arm_cfft_q15(&arm_cfft_sR_q15_len256, Buffer_samples, 0, 1); arm_cmplx_mag_q15(Buffer_samples, magoutput, fftlength); CyDmaChEnable(DMA_2_Chan, 1); isr_BC_flag=0; isr_1_ClearPending(); } } }
int main() { uint8 buffer[10] = {0}; int i; /* Place your initialization/startup code here (e.g. MyInst_Start()) */ CyGlobalIntEnable; /* Uncomment this line to enable global interrupts. */ UART_1_Start(); //UART_1_EnableTxInt(); //UART_1_EnableRxInt(); isr_1_StartEx(isr_1_isr); isr_1_Enable(); for(;;) { for(i = 0;i < 4;i++) { buffer[i] = rx_buffer[i]; } } }