void system_init(void) { rcc_clock_setup_hse_3v3(&hse_8mhz_3v3[CLOCK_3V3_168MHZ]); leds_init(); hall_init(); cdcacm_init(); printled(4, LRED); tim_init(); adc_init(); test_ports_init(); stdin_init(); }
static void __init omap_4430sdp_init(void) { int package = OMAP_PACKAGE_CBS; if (omap_rev() == OMAP4430_REV_ES1_0) package = OMAP_PACKAGE_CBL; omap4_mux_init(board_mux, NULL, package); lpddr_init(); omap_board_config = sdp4430_config; omap_board_config_size = ARRAY_SIZE(sdp4430_config); omap_init_board_version(0); omap4_create_board_props(); blaze_pmic_mux_init(); omap4_i2c_init(); /* JossCheng, 20111221, Porting gyro sensor and e-compass {*/ #ifdef CONFIG_MPU_SENSORS_MPU6050B1 mpu6050b1_init(); #endif /* JossCheng, 20111221, Porting gyro sensor and e-compass }*/ //blaze_sensor_init(); // Anvoi, 2011/12/14, Porting Light sensor driver to ICS omap4_als_init(); // Anvoi, 2011/12/14, Porting Light sensor driver to ICS //blaze_touch_init(); omap4_register_ion(); /*SW5, Anvoi, 20111215, Config key VolumeUp/VolumeDown{*/ platform_add_devices(bowser_devices, ARRAY_SIZE(bowser_devices)); /*SW5, Anvoi, 20111215, Config key VolumeUp/VolumeDown}*/ #if defined (CONFIG_TATE_HALL_SENSORS) hall_init(); #endif board_serial_init(); omap4_twl6030_hsmmc_init(mmc); bowser_wifi_init(); omap4_sdp4430_bt_init(); omap4_ehci_ohci_init(); usb_musb_init(&musb_board_data); // BokeeLi, 2011/12/14, Porting proximity driver #ifdef CONFIG_INPUT_PIC12LF1822_PROXIMITY omap4_proximity_init(); #endif // BokeeLi, 2011/12/14, Porting proximity driver /*SW5, Jamestsai, 1213, enable cypress{*/ #if defined(CONFIG_TOUCHSCREEN_CYPRESS_TTSP) || (CONFIG_TOUCHSCREEN_ATMEL_MXT) || defined(CONFIG_TOUCHSCREEN_ATMEL_MXT_MODULE) omap4_touch_init(); #endif /*}SW5, Jamestsai, 1213, enable cypress*/ omap_dmm_init(); //omap_4430sdp_display_init(); bowser_panel_init(); omap_enable_smartreflex_on_init(); if (enable_suspend_off) omap_pm_enable_off_mode(); }
int main() { static uint16_t pulse_width; DDRB = 0; DDRD = 0; LED_DDR |= LED_BITS; // LED pins out DDRB |= (1<<PB4); // PWM out PORTD = (1<<PD2)|(1<<PD3); // pullups for sensors PORTB = (1<<PB0)|(1<<PB1)|(1<<PB2); // pullups for switches timer_init(); hall_init(); sei(); // enable interrupts. uint16_t pwm_stop_val = (PW_MIN+PW_MAX)/2+PW_TUNED_STOP; OCR1B = pulse_width = pwm_stop_val; // start stopped. #define BAUD 19200 rs232_init(UBRV(BAUD), &rs232_recv); uint16_t counter = 0; uint8_t paused = 0; uint8_t button_seen = 0; int16_t incr_counter = 0; for (;;) { if (!button_seen) { if ((PINB & (1<<PB0)) || cmd_seen == '+' || cmd_seen == 'l') { if (!cmd_seen) button_seen = 1; if (paused) { pulse_width = pwm_stop_val; incr_counter = 0; } incr_counter++; pulse_width = pwm_stop_val + speedup(incr_counter) * PW_BUT_INCR; if (pulse_width > PW_MAX) pulse_width = PW_MAX; paused = 0; rs232_send('l'); } if ((PINB & (1<<PB2)) || cmd_seen == '-' || cmd_seen == 'r') { if (!cmd_seen) button_seen = 1; if (paused) { pulse_width = pwm_stop_val; incr_counter = 0; } incr_counter--; pulse_width = pwm_stop_val + speedup(incr_counter) * PW_BUT_INCR; if (pulse_width < PW_MIN) pulse_width = PW_MIN; paused = 0; rs232_send('r'); } if ((PINB & (1<<PB1)) || cmd_seen == ' ') { if (!cmd_seen) button_seen = 1; if (paused) { paused = 0; rs232_send('g'); } else { paused = 1; rs232_send('p'); } } } else { // disable automatic key repeat if (!(PINB & ((1<<PB0)|(1<<PB1)|(1<<PB2)))) button_seen = 0; // need a release before press. if (cmd_seen) rs232_send('!'); } if (paused) OCR1B = pwm_stop_val; else OCR1B = pulse_width; if (cmd_seen) { cmd_seen = 0; // very small race rs232_send_hex(pulse_width>>8); rs232_send_hex(pulse_width&0xff); rs232_send(' '); rs232_send_hex(hall_counter>>8); rs232_send_hex(hall_counter&0xff); rs232_send('\r'); rs232_send('\n'); } if (!(counter++ % 8)) // (1<<(led_what-1)))) { _delay_ms(10.0); if (pulse_width > pwm_stop_val) LED_PORT |= GREEN_LED_BITS; // pull high ... if (pulse_width < pwm_stop_val) LED_PORT |= RED_LED_BITS; // pull high ... _delay_ms(10.0); if (paused) LED_PORT &= ~(LED_BITS); // pull low ... _delay_ms(80.0); if (!paused) LED_PORT &= ~(LED_BITS); // pull low ... } else { _delay_ms(100.0); } } }