/* returns * - success: 0 */ uint8_t teensy_init(void) { CPU_PRESCALE(CPU_16MHz); // speed should match F_CPU in makefile // onboard LED DDRD &= ~(1<<6); // set D(6) as input PORTD &= ~(1<<6); // set D(6) internal pull-up disabled // keyboard LEDs (see "PWM on ports OC1(A|B|C)" in "teensy-2-0.md") _led_all_off(); // (just to put the pins in a known state) TCCR1A = 0b10101001; // set and configure fast PWM TCCR1B = 0b00001001; // set and configure fast PWM // I2C (TWI) twi_init(); // on pins D(1,0) // unused pins teensypin_write_all_unused(DDR, CLEAR); // set as input teensypin_write_all_unused(PORT, SET); // set internal pull-up enabled // rows teensypin_write_all_row(DDR, CLEAR); // set as input teensypin_write_all_row(PORT, SET); // set internal pull-up enabled // columns teensypin_write_all_column(DDR, CLEAR); // set as input (hi-Z) teensypin_write_all_column(PORT, CLEAR); // set internal pull-up // disabled return 0; // success }
/* returns * - success: 0 */ uint8_t teensy_init(void) { // CPU speed : should match F_CPU in makefile #if F_CPU != 16000000 #error "Expecting different CPU frequency" #endif CPU_PRESCALE(CPU_16MHz); // onboard LED // (tied to GND for hardware convenience) DDRD &= ~(1<<6); // set D(6) as input PORTD &= ~(1<<6); // set D(6) internal pull-up disabled // (tied to Vcc for hardware convenience) DDRB &= ~(1<<4); // set B(4) as input PORTB &= ~(1<<4); // set B(4) internal pull-up disabled // keyboard LEDs (see "PWM on ports OC1(A|B|C)" in "teensy-2-0.md") _kb_led_all_off(); // (just to put the pins in a known state) TCCR1A = 0b10101001; // set and configure fast PWM TCCR1B = 0b00001001; // set and configure fast PWM // I2C (TWI) twi_init(); // on pins D(1,0) // unused pins teensypin_write_all_unused(DDR, CLEAR); // set as input teensypin_write_all_unused(PORT, SET); // set internal pull-up enabled // rows and columns teensypin_write_all_row(DDR, CLEAR); // set as input (hi-Z) teensypin_write_all_column(DDR, CLEAR); // set as input (hi-Z) #if TEENSY__DRIVE_ROWS teensypin_write_all_row(PORT, CLEAR); // pull-up disabled teensypin_write_all_column(PORT, SET); // pull-up enabled #elif TEENSY__DRIVE_COLUMNS teensypin_write_all_row(PORT, SET); // pull-up enabled teensypin_write_all_column(PORT, CLEAR); // pull-up disabled #endif return 0; // success }