// ISR for GPIOF void GPIOF_Handler(void) { if (GetBit32(GPIOF->RIS, 0)) { if (g_mode == MODE1) { // Switch audio range } else { g_enable_play = 1; } SetBit32( &(GPIOF->ICR), 0, 1); } else if (GetBit32(GPIOF->RIS, 4)) { //SetBit32( &(GPIOF->DATA), 3, 1 ); if (!g_enable_play) { if (g_mode == MODE1) { g_mode = MODE2; SetBit32( &(GPIOF->DATA), 1, 0 ); SetBit32( &(GPIOF->DATA), 2, 1 ); SetBit32( &(GPIOF->DATA), 3, 0 ); PWM_set_duty_cycle(100); } else if (g_mode == MODE2) { g_mode = MODE3; SetBit32( &(GPIOF->DATA), 1, 0 ); SetBit32( &(GPIOF->DATA), 2, 0 ); SetBit32( &(GPIOF->DATA), 3, 1 ); PWM_set_duty_cycle(100); } else { g_mode = MODE1; SetBit32( &(GPIOF->DATA), 1, 1 ); SetBit32( &(GPIOF->DATA), 2, 0 ); SetBit32( &(GPIOF->DATA), 3, 0 ); } } SetBit32( &(GPIOF->ICR), 4, 1); } // Clear pending bit NVIC->ICPR[0] = 0x1UL << 30; }
//===================================================================== // Create the OS Page Table referred to by the above Page Directory // This does no remapping - each Logical Address is mapped to the same // Physical Address. This covers Physical Addresses from 0 to 0x200000. //===================================================================== void CreatePT164(struct PT * pt, int i) { // unsigned char *PMap = (unsigned char *) PageMap; int count; pt->entries[0].Hi = 0; pt->entries[0].Lo = P | RW; //for (count = 1; count < 0x10; count++) //{ // pt->entries[count].Hi = 0; // pt->entries[count].Lo = (count << 12) | P | RW | G; //} // Kernel initialized datadata //for (count = 0x10; count < 0x100; count++) // if (PMap[count] == 1) // { // pt->entries[count].Hi = 0; // pt->entries[count].Lo = (count << 12) | P | RW | G; // } // PageTab for (count = 0x0 + i * 0x200; count < 0x200 + i * 0x200; count++) if (GetBit32(count)) { pt->entries[count].Hi = 0; pt->entries[count].Lo = (count << 12) | P | RW | G; } }
void Timer_delay(uint16_t delayInMilliSeconds) { // Calculate the counter reload value uint32_t timedInterval = delayInMilliSeconds * 0.001 * SYSTEM_CLOCK_FREQUENCY; uint32_t counterReloadValue = (timedInterval/(PRESCALE_VALUE+1)) - 1; // Configure counter reload value TIMER0->TAILR = counterReloadValue; // Enable TimerA SetBit32( &(TIMER0->CTL), 0, 1 ); // Loops until timer event has elapsed while (1) { // Check to see if timer event has elapsed if (GetBit32( TIMER0->CTL, 0 ) == 0) { break; } } }