///////////////////////////////////////////////////////////////////////////// //! Initializes the BLM_CHEAPO driver //! Should be called from Init() during startup //! \param[in] mode currently only mode 0 supported //! \return < 0 if initialisation failed ///////////////////////////////////////////////////////////////////////////// s32 BLM_CHEAPO_Init(u32 mode) { if( mode != 0 ) return -1; // only mode 0 supported // initialize J15 pins for open drain mode MIOS32_BOARD_J15_PortInit(1); // initialize all J10 pins as inputs with internal Pull-Up int pin; for(pin=0; pin<8; ++pin) MIOS32_BOARD_J10_PinInit(pin, MIOS32_BOARD_PIN_MODE_INPUT_PU); // initialize all pins of J5A and J5B as outputs in Push-Pull Mode for(pin=0; pin<8; ++pin) MIOS32_BOARD_J5_PinInit(pin, MIOS32_BOARD_PIN_MODE_OUTPUT_PP); int row; for(row=0; row<NUM_ROWS; ++row) { button_row[row] = 0xff; button_row_changed[row] = 0x00; } selected_row = 0; button_debounce_ctr = 0; button_debounce_reload = 10; // mS return 0; // no error }
///////////////////////////////////////////////////////////////////////////// // Initializes application specific LCD driver // IN: <mode>: optional configuration // OUT: returns < 0 if initialisation failed ///////////////////////////////////////////////////////////////////////////// s32 APP_LCD_Init(u32 mode) { // currently only mode 0 supported if( mode != 0 ) return -1; // unsupported mode if( MIOS32_BOARD_J15_PortInit(APP_LCD_OUTPUT_MODE) < 0 ) return -2; // failed to initialize J15 #if APP_LCD_USE_J10_FOR_CS int pin; for(pin=0; pin<8; ++pin) MIOS32_BOARD_J10_PinInit(pin, APP_LCD_OUTPUT_MODE ? MIOS32_BOARD_PIN_MODE_OUTPUT_OD : MIOS32_BOARD_PIN_MODE_OUTPUT_PP); #endif // set LCD type mios32_lcd_type = MIOS32_LCD_TYPE_GLCD; // initialize LCD APP_LCD_Cmd(0xa8); // Set MUX Ratio APP_LCD_Cmd(0x3f); APP_LCD_Cmd(0xd3); // Set Display Offset APP_LCD_Cmd(0x00); APP_LCD_Cmd(0x40); // Set Display Start Line APP_LCD_Cmd(0xa0); // Set Segment re-map APP_LCD_Cmd(0xc0); // Set COM Output Scan Direction APP_LCD_Cmd(0xda); // Set COM Pins hardware configuration APP_LCD_Cmd(0x12); APP_LCD_Cmd(0x81); // Set Contrast Control APP_LCD_Cmd(0x7f); // middle APP_LCD_Cmd(0xa4); // Disable Entiere Display On APP_LCD_Cmd(0xa6); // Set Normal Display APP_LCD_Cmd(0xd5); // Set OSC Frequency APP_LCD_Cmd(0x80); APP_LCD_Cmd(0x8d); // Enable charge pump regulator APP_LCD_Cmd(0x14); APP_LCD_Cmd(0xaf); // Display On APP_LCD_Cmd(0x20); // Enable Page mode APP_LCD_Cmd(0x02); return (display_available & (1 << mios32_lcd_device)) ? 0 : -1; // return -1 if display not available }
///////////////////////////////////////////////////////////////////////////// // Initializes application specific VFD driver // IN: <mode>: optional configuration // OUT: returns < 0 if initialisation failed ///////////////////////////////////////////////////////////////////////////// s32 APP_LCD_Init(u32 mode) { MIOS32_BOARD_J15_PortInit(APP_LCD_OUTPUT_MODE); MIOS32_BOARD_J15_RS_Set(0); MIOS32_BOARD_J15_RW_Set(0); APP_LCD_Cmd(0b00110011); APP_LCD_Cmd(0b00110010); APP_LCD_Cmd(0b00101000); // 4bit, 2 lines APP_LCD_Cmd(0b00001100); // display on, cursor off, char blinking off APP_LCD_Cmd(0b00000110); // entry mode APP_LCD_Cmd(0b00000001); // clear return 0; }
///////////////////////////////////////////////////////////////////////////// // Initializes application specific LCD driver // IN: <mode>: optional configuration // OUT: returns < 0 if initialisation failed ///////////////////////////////////////////////////////////////////////////// s32 APP_LCD_Init(u32 mode) { // currently only mode 0 supported if( mode != 0 ) return -1; // unsupported mode if( MIOS32_BOARD_J15_PortInit(APP_LCD_OUTPUT_MODE) < 0 ) return -2; // failed to initialize J15 // enable display by default display_available |= (1 << mios32_lcd_device); // set LCD type mios32_lcd_parameters.lcd_type = MIOS32_LCD_TYPE_GLCD_CUSTOM; mios32_lcd_parameters.num_x = APP_LCD_NUM_X; mios32_lcd_parameters.width = APP_LCD_WIDTH; mios32_lcd_parameters.num_x = APP_LCD_NUM_Y; mios32_lcd_parameters.height = APP_LCD_HEIGHT; mios32_lcd_parameters.colour_depth = APP_LCD_COLOUR_DEPTH; // initialize LCD #ifdef MIOS32_DONT_USE_DELAY u32 delay; for(delay=0; delay<50000; ++delay) MIOS32_BOARD_J15_RW_Set(0); // ca. 50 mS Delay #else MIOS32_DELAY_Wait_uS(50000); // exact 50 mS delay #endif APP_LCD_Cmd(0xf1); APP_LCD_Cmd(0x67); APP_LCD_Cmd(0xc0); APP_LCD_Cmd(0x40); APP_LCD_Cmd(0x50); APP_LCD_Cmd(0x2b); APP_LCD_Cmd(0xeb); APP_LCD_Cmd(0x81); APP_LCD_Cmd(0x58); // contrast(0x00-0xff Default 0x5f APP_LCD_Cmd(0x89); //APP_LCD_Cmd(0xd0); //Greyscale control APP_LCD_Cmd(0xaf); return (display_available & (1 << mios32_lcd_device)) ? 0 : -1; // return -1 if display not available }