void initializeSystem(void) { CyGlobalIntEnable; UART_Start(); PrISM_1_Start(); PrISM_2_Start(); Opamp_1_Start(); // Start the Bluetooth Stack CyBle_Start(CustomEventHandler); // Set up the LED. First set its output to be off so that the LED doesn't blink on. // Then set the drive mode to strong. PrISM_1_WritePulse0(255); PrISM_1_WritePulse1(255); PrISM_2_WritePulse0(255); RED_SetDriveMode(RED_DM_STRONG); GREEN_SetDriveMode(GREEN_DM_STRONG); BLUE_SetDriveMode(BLUE_DM_STRONG); // Start the ADC ADC_SAR_Seq_Start(); ADC_SAR_Seq_StartConvert(); ADC_SAR_Seq_IRQ_Enable(); // Enable an interupt for when the ADC has data ADC_SAR_Seq_IRQ_StartEx(ADC_SAR_Seq_ISR_LOC); // Start the Timer for the ADC ADC_Timer_Start(); elapsed = 0; }
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() { /* Place your initialization/startup code here (e.g. MyInst_Start()) */ Opamp_1_Start(); Opamp_3_Start(); Clock_1_Start(); ADC_DelSig_1_Start(); ADC_DelSig_1_StartConvert(); VDAC8_1_Start(); VDAC8_2_Start(); CyGlobalIntEnable; /* Uncomment this line to enable global interrupts. */ isr_StartEx(filterVDAC); for(;;) { /* Place your application code here. */ } }
int main() { /* Start all components used on schematic */ VDAC8_1_Start(); VDAC8_2_Start(); Opamp_1_Start(); Opamp_2_Start(); Filter_Start(); Timer_Start(); ISR_Timer_StartEx(Timer_interrupt_handler); /* Enable the interrupt register bit to poll Value 1 for Channel A, Value 2 for Channel B */ Filter_INT_CTRL_REG |= (1 << Filter_CHANNEL_A); CyGlobalIntEnable; for(;;) { //CyDelay(10); } } /* End of main */