int main(void) { int playPauseButton, playPauseButtonPrev, stopButton, stopButtonPrev; // Music output port. The DAC MUST use pins 0-3 on the port! Port dac = portInit('YOUR PORT LETTER HERE', 0x00, 0x0F); // port used for the play/pause and stop buttons // and the LED outputs (one for tempo/beat, one to show a note is playing) io = portInit(/* YOUR PORT INFO HERE*/); musicInit(dac); musicLoad(/* YOUR SONG INFO HERE */); // Main loop while(TRUE) { // Read inputs and call one of: // musicPlay() // musicPause() // musicStop() if (playing == TRUE) { WaitForInterrupt(); } } }
/** Configures hardware for the particular hardware platform: - Ports: sets direction, interrupts, pullup/pulldown resistors etc. - Holds radio in reset (active-low) */ void halInit() { // // Enable the floating-point unit. // FPUEnable(); // // Configure the floating-point unit to perform lazy stacking of the // floating-point state. // FPULazyStackingEnable(); oscInit(); portInit(); halUartInit(); //Point the function pointers to doNothing() so that they don't trigger a restart debugConsoleIsr = &doNothing; buttonIsr = &doNothing; clearLeds(); displayVersion(); #ifdef AF_VERBOSE printf("* AF_VERBOSE *\r\n"); #endif }
/** \fn main * \brief Function that is called after start up * * Initializes the R_RTOS and calls os_StartOS */ int main( void ) { __disable_irq(); portInit(); #ifdef __LP__MODE__ /* WAKE UP SOURCES */ addWakeUpSource( LLWU_LPTMR0, 0x0u ); NVIC_ClearPendingIRQ( LLWU_IRQn ); addWakeUpSource( LLWU_PTB2, INT_FALL ); /* WAKE UP SOURCES \ */ #endif __initOS(); __enable_irq(); // CALL OS START svc_os_StartOS(); // do forever while ( 1 ) { } /* Never leave main */ return 0; }
/** * @note It takes five clock cycles after SysCtlPeripheralEnable() is called to enable a peripheral before the the peripheral is actually enabled. During this time, attempts to access the peripheral will result in a bus fault. Care should be taken to ensure that the peripheral is not accessed during this brief time period. */ void halInit() { oscInit(); portInit(); SysCtlPeripheralEnable(SYSCTL_PERIPH_ETH); SysCtlPeripheralReset(SYSCTL_PERIPH_ETH); //Point the function pointers to doNothing() so that they don't trigger a restart //debugConsoleIsr = &doNothing; buttonIsr = &doNothing; }
Keyboard::Keyboard(FILE *S){ // Serial Stream=S; #else Keyboard::Keyboard(){ #endif // Init ports portInit(); // States for(int i=0;i<NUM_KEYS;i++) keyState[i]=false; keypad=false; fn=false; fn_used=false; LEDReport=NO_LED_REPORT; last_USB_DeviceState=NO_USB_DEVICE_STATE; last_USB_Device_RemoteWakeupEnabled=USB_Device_RemoteWakeupEnabled; KeyboardReport=NULL; macroState=MACRO_STATE_NONE; macroLocked=true; // Key preses keyPressesInit(); // Load layout layout=eeprom_read_byte((const uint8_t *)EEPROM_LAYOUT); if(layout>LAYOUT_MAX){ layout=US_US; eeprom_write_byte((uint8_t *)EEPROM_LAYOUT, layout); } // Sequences sequence=NULL; // Display displayInit(); displayUpdating=0; displayUpdateAgain=false; } // // C bindings // extern Keyboard *kbd; void keyboardScanAll(USB_KeyboardReport_Data_t *KR){ kbd->KeyboardReport=KR; kbd->scanAll(); }
/** * Configures hardware for the particular board * - Initializes clocks * - Ports: including purpose, direction, pullup/pulldown resistors etc. * - Holds radio in reset (active-low) */ void halInit() { oscInit(); portInit(); DEBUG_CONSOLE_INIT(BAUD_RATE_19200); AUX_SERIAL_PORT_INIT(BAUD_RATE_115200); //Module uses 115,200 8N1 WITH FLOW CONTROL // // Deselect SPI peripherals: // SPI_SS_CLEAR(); // Deselect Module // Stop Timer A: TACTL = MC_0; debugConsoleIsr = &doNothing; buttonIsr = &doNothing; halSpiInitModule(); }
void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer clockSetup(); portInit(); initializeB0I2C(); // int myConfig = ADS_OS | ADS_PGA_2 | ADS_128Hz | ADS_ALERT_NO | ADS_CONV1; int myConfig = ADS_PGA_2 | ADS_475Hz | ADS_ALERT_NO | ADS_CONVC; myADC = registerADS(ADS_01, ADS_DEFAULTC); // myADC = registerADS(ADS_01,ADS_DEFAULTC); setADS(myADC); _enable_interrupts(); startADS(); while (1) { a = readADS(); } }
LCD::LCD() { portInit(); set4bit(); init(); }
void main(void) { portInit(); //initialize ports, interrupts, and motors for(;;); //do nothing forever (interrupt driven) }