// Write a specific 8x8 pattern void led_write(uint8_t (*pattern)[8][8]) { for(int row = 0; row <= 7; row++) { g_green[row] = 0; g_red[row] = 0; for(int col = 0; col <= 7; col++) { if((*pattern)[row][col] == RED) { g_red[row] |= (1 << col); } else if((*pattern)[row][col] == GREEN) { g_green[row] |= (1 << col); } else if((*pattern)[row][col] == ORANGE) { g_red[row] |= (1 << col); g_green[row] |= (1 << col); } else if((*pattern)[row][col] == BLACK) { } else { printf("Unknown color in pattern\n"); } } } g_row = 0; // Every 3 ms, the PIT will trigger the next row to be refreshed pit0_stop(); pit0_init(); }
void main(void) #endif { USB_STATUS status = USB_OK; _usb_host_handle host_handle; boolean send = TRUE; /* Initialize the current platform. Call for the _bsp_platform_init which is specific to each processor family */ _bsp_platform_init(); #ifdef MCU_MK70F12 sci2_init(); #else sci1_init(); #endif TimerInit(); /* Init polling global variable */ POLL_init(); #if (defined(_MCF51MM256_H) || (defined _MCF51JE256_H)) cmt_init(); Mcu_Init(); Kbi_Init(); pwm_init(); #endif #if (defined(__MCF52259_H__) || (defined (__MCF52221_H__)) ||(defined (_MK_xxx_H_)) ) GPIO_Init(); pit0_init(); pwm_init(); #endif #if (defined MCU_mcf51jf128) GPIO_Init(); mtim_init(); pwm_init(); #endif DisableInterrupts; #if (defined _MCF51MM256_H) || (defined _MCF51JE256_H) usb_int_dis(); #endif /* ** It means that we are going to act like host, so we initialize the ** host stack. This call will allow USB system to allocate memory for ** data structures, it uses later (e.g pipes etc.). */ status = _usb_host_init ( HOST_CONTROLLER_NUMBER, /* Use value in header file */ MAX_FRAME_SIZE, /* Frame size per USB spec */ &host_handle); /* Returned pointer */ if (status != USB_OK) { printf("\nUSB Host Initialization failed! STATUS: 0x%x", (unsigned int) status); fflush(stdout); exit(3); } status = _usb_host_driver_info_register ( host_handle, (pointer)DriverInfoTable ); if (status != USB_OK) { printf("\nDriver Registration failed! STATUS: 0x%x",(unsigned int) status); fflush(stdout); exit(4); } EnableInterrupts; #if (defined _MCF51MM256_H) || (defined _MCF51JE256_H) usb_int_en(); #endif printf("USB Host Audio Demo\r\nWaitting for USB Audio Device to be attached...\r\n"); _usb_event_init(&USB_Event); for(;;) { Poll(); Audio_Task(); __RESET_WATCHDOG(); /* feeds the dog */ } /* loop forever */ /* please make sure that you never leave main */ #ifdef __GNUC__ return 0; #endif }