/** Configures the board hardware and chip peripherals for the demo's functionality. */ void SetupHardware(void) { #if (ARCH == ARCH_AVR8) /* Disable watchdog if enabled by bootloader/fuses */ MCUSR &= ~(1 << WDRF); wdt_disable(); /* Disable clock division */ clock_prescale_set(clock_div_1); #endif /* Hardware Initialization */ LEDs_Init(); ADC_Init(ADC_FREE_RUNNING | ADC_PRESCALE_128); Temperature_Init(); Dataflash_Init(); USB_Init(); TWI_Init(TWI_BIT_PRESCALE_4, TWI_BITLENGTH_FROM_FREQ(4, 50000)); RTC_Init(); /* 500ms logging interval timer configuration */ OCR1A = (((F_CPU / 256) / 2) - 1); TCCR1B = (1 << WGM12) | (1 << CS12); TIMSK1 = (1 << OCIE1A); /* Check if the Dataflash is working, abort if not */ if (!(DataflashManager_CheckDataflashOperation())) { LEDs_SetAllLEDs(LEDMASK_USB_ERROR); for(;;); } /* Clear Dataflash sector protections, if enabled */ DataflashManager_ResetDataflashProtections(); }
/** Configures the board hardware and chip peripherals for the demo's functionality. */ void SetupHardware(void) { /* Disable watchdog if enabled by bootloader/fuses */ MCUSR &= ~(1 << WDRF); wdt_disable(); /* Disable clock division */ clock_prescale_set(clock_div_1); /* Hardware Initialization */ LEDs_Init(); SPI_Init(SPI_SPEED_FCPU_DIV_2 | SPI_SCK_LEAD_FALLING | SPI_SAMPLE_TRAILING | SPI_MODE_MASTER); ADC_Init(ADC_FREE_RUNNING | ADC_PRESCALE_128); Temperature_Init(); Dataflash_Init(); USB_Init(); TWI_Init(TWI_BIT_PRESCALE_4, TWI_BITLENGTH_FROM_FREQ(4, 50000)); /* 500ms logging interval timer configuration */ OCR1A = (((F_CPU / 1024) / 2) - 1); TCCR1B = (1 << WGM12) | (1 << CS12) | (1 << CS10); TIMSK1 = (1 << OCIE1A); /* Clear Dataflash sector protections, if enabled */ DataflashManager_ResetDataflashProtections(); }
void SetupHardware(void) { /* Disable watchdog if enabled by bootloader/fuses */ MCUSR &= ~(1 << WDRF); wdt_disable(); /* Disable clock division */ clock_prescale_set(clock_div_1); /* Hardware Initialization */ USB_Init(); // http://avrbeginners.net/architecture/spi/spi.html SPI_Init(SPI_SPEED_FCPU_DIV_32 | SPI_SCK_LEAD_FALLING | SPI_SAMPLE_LEADING | SPI_ORDER_MSB_FIRST | SPI_MODE_MASTER); //initialize TWI-Bus TWI_Init(TWI_BIT_PRESCALE_1, TWI_BITLENGTH_FROM_FREQ(1, 200000)); //check wether to load data at boot and do it if (eeprom_read_byte((uint8_t*)EEPROM_BOOT_VALUES) == 0x10 ) { for (int i = 0; i < ConfigSize; i++) { uint8_t eeprom_addr = EEPROM_CONFIG_OFFSET + i; DeviceConfig[i] = eeprom_read_byte((uint8_t*)eeprom_addr); } Output_data(); } }
/* 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); // PD2 as interrupt for N35P112 DDRD &=~ (1 << 2); //Input PORTD |= (1 << 2); //Use Pullup // PD3 as reset for N35P112 DDRD |= (1 << 3); //Output // PB7 as pushbutton for N35P112 DDRB &=~ (1 << 7); //Input PORTB &=~ (1 << 7); //No Pullup // I2C (TWI) uint8_t twiPrescaler = TWI_BIT_PRESCALE_1; uint8_t twiBitRate = TWI_BITLENGTH_FROM_FREQ(1, TWI_FREQ); TWI_Init(twiPrescaler, twiBitRate); return 0; // success }
void matrix_init_user(void) { #ifdef AUDIO_ENABLE startup_user(); #endif #ifdef RGBLIGHT_ENABLE RGB_current_mode = rgblight_config.mode; #endif //SSD1306 OLED init, make sure to add #define SSD1306OLED in config.h #ifdef SSD1306OLED TWI_Init(TWI_BIT_PRESCALE_1, TWI_BITLENGTH_FROM_FREQ(1, 800000)); iota_gfx_init(!has_usb()); // turns on the display #endif }
void matrix_init_user(void) { #ifdef USE_I2C i2c_master_init(); #ifdef SSD1306OLED // calls code for the SSD1306 OLED _delay_ms(400); TWI_Init(TWI_BIT_PRESCALE_1, TWI_BITLENGTH_FROM_FREQ(1, 800000)); iota_gfx_init(); // turns on the display #endif #endif #ifdef AUDIO_ENABLE startup_user(); #endif }
/** Configures the board hardware and chip peripherals for the demo's functionality. */ void SetupHardware(void) { #if (ARCH == ARCH_AVR8) /* Disable watchdog if enabled by bootloader/fuses */ MCUSR &= ~(1 << WDRF); wdt_disable(); /* Disable clock division */ clock_prescale_set(clock_div_1); #elif (ARCH == ARCH_XMEGA) /* Start the PLL to multiply the 2MHz RC oscillator to 32MHz and switch the CPU core to run from it */ XMEGACLK_StartPLL(CLOCK_SRC_INT_RC2MHZ, 2000000, F_CPU); XMEGACLK_SetCPUClockSource(CLOCK_SRC_PLL); /* Start the 32MHz internal RC oscillator and start the DFLL to increase it to 48MHz using the USB SOF as a reference */ XMEGACLK_StartInternalOscillator(CLOCK_SRC_INT_RC32MHZ); XMEGACLK_StartDFLL(CLOCK_SRC_INT_RC32MHZ, DFLL_REF_INT_USBSOF, F_USB); PMIC.CTRL = PMIC_LOLVLEN_bm | PMIC_MEDLVLEN_bm | PMIC_HILVLEN_bm; #endif /* Hardware Initialization */ //i2c TWI_Init(TWI_BIT_PRESCALE_1, TWI_BITLENGTH_FROM_FREQ(1, 400000)); //button ports init buttons_init(); //timer init TCCR1B |=(1<<CS10)|(1<<CS12);//prescaler 1024 TCNT1 = 0;//init counter //screen setup - software spi, sh1106 driver (sh1306 analog) /* Atmega32U4 mapping: SCK (D0) - PORTB, PIN1 == PN(1, 1) MOSI (D1) - PORTB, PIN2 RES (RST) - PORTB, PIN0 A0 (DC) - PORTB, PIN5 (OC1A/#A9) */ display_init(); display_draw_logo(); //sensors initialization adxl345_init(MEASURE_ON, RANGE_2G, ODR_800); l3g4200d_init(FIFO_HI_LO_PASS, NORM_ODR_800); hmc5883l_init(MODE_CONT, GAIN_4_7, NORM_75HZ_8AV); USB_Init(); }
void SetupHardware(void) { MY_SetLedAll(true); MY_Setup(); USB_Init(); LCD_Setup(); TWI_Init(TWI_BIT_PRESCALE_1, TWI_BITLENGTH_FROM_FREQ(1, 400000)); Serial_Init(2000000, true); // noisy thing PORTC &= ~(1 << 6); DDRC |= (1 << 6); // don't txen PORTD &= ~(1 << 4); PORTD |= (1 << 2); // pull-up DDRD |= (1 << 4); }
void matrix_master_OLED_init (void) { TWI_Init(TWI_BIT_PRESCALE_1, TWI_BITLENGTH_FROM_FREQ(1, 800000)); iota_gfx_init(0); // turns on the display }