/*---------------------------------------------------------------------------*/ void leds_arch_set(unsigned char leds) { c = leds; ti_lib_gpio_pin_write(BOARD_LED_ALL, 0); if((leds & LEDS_RED) == LEDS_RED) { ti_lib_gpio_pin_write(BOARD_LED_1, 1); } if((leds & LEDS_YELLOW) == LEDS_YELLOW) { ti_lib_gpio_pin_write(BOARD_LED_2, 1); } }
/*---------------------------------------------------------------------------*/ static void power_up(void) { ti_lib_gpio_pin_write(BOARD_MPU_POWER, 1); state = SENSOR_STATE_BOOTING; ctimer_set(&startup_timer, SENSOR_BOOT_DELAY, initialise, NULL); }
/*---------------------------------------------------------------------------*/ static void configure_unused_pins(void) { /* Turn off 3.3-V domain (lcd/sdcard power, output low) */ ti_lib_ioc_pin_type_gpio_output(BOARD_IOID_3V3_EN); ti_lib_gpio_pin_write(BOARD_3V3_EN, 0); /* Accelerometer (PWR output low, CSn output, high) */ ti_lib_ioc_pin_type_gpio_output(BOARD_IOID_ACC_PWR); ti_lib_gpio_pin_write(BOARD_ACC_PWR, 0); /* Ambient light sensor (off, output low) */ ti_lib_ioc_pin_type_gpio_output(BOARD_IOID_ALS_PWR); ti_lib_gpio_pin_write(BOARD_ALS_PWR, 0); ti_lib_ioc_pin_type_gpio_input(BOARD_IOID_ALS_OUT); ti_lib_ioc_io_port_pull_set(BOARD_IOID_ALS_OUT, IOC_NO_IOPULL); }
/*---------------------------------------------------------------------------*/ void board_init() { /* Disable global interrupts */ uint8_t int_disabled = ti_lib_int_master_disable(); power_domains_on(); /* Configure all clock domains to run at full speed */ ti_lib_prcm_clock_configure_set(PRCM_DOMAIN_SYSBUS, PRCM_CLOCK_DIV_1); ti_lib_prcm_clock_configure_set(PRCM_DOMAIN_CPU, PRCM_CLOCK_DIV_1); ti_lib_prcm_clock_configure_set(PRCM_DOMAIN_TIMER, PRCM_CLOCK_DIV_1); ti_lib_prcm_clock_configure_set(PRCM_DOMAIN_SERIAL, PRCM_CLOCK_DIV_1); ti_lib_prcm_clock_configure_set(PRCM_DOMAIN_PERIPH, PRCM_CLOCK_DIV_1); /* Enable GPIO peripheral */ ti_lib_prcm_peripheral_run_enable(PRCM_PERIPH_GPIO); /* Apply settings and wait for them to take effect */ ti_lib_prcm_load_set(); while(!ti_lib_prcm_load_get()); /* Enable GPT0 module - Wait for the clock to be enabled */ ti_lib_prcm_peripheral_run_enable(PRCM_PERIPH_TIMER0); ti_lib_prcm_load_set(); while(!ti_lib_prcm_load_get()); /* Keys (input pullup) */ ti_lib_rom_ioc_pin_type_gpio_input(BOARD_IOID_KEY_LEFT); ti_lib_rom_ioc_pin_type_gpio_input(BOARD_IOID_KEY_RIGHT); ti_lib_ioc_io_port_pull_set(BOARD_IOID_KEY_LEFT, IOC_IOPULL_UP); ti_lib_ioc_io_port_pull_set(BOARD_IOID_KEY_RIGHT, IOC_IOPULL_UP); /* I2C controller */ board_i2c_init(); /* Sensor interface */ ti_lib_rom_ioc_pin_type_gpio_input(BOARD_IOID_MPU_INT); ti_lib_ioc_io_port_pull_set(BOARD_IOID_MPU_INT, IOC_IOPULL_DOWN); ti_lib_rom_ioc_pin_type_gpio_input(BOARD_IOID_REED_RELAY); ti_lib_ioc_io_port_pull_set(BOARD_IOID_REED_RELAY, IOC_IOPULL_DOWN); ti_lib_rom_ioc_pin_type_gpio_output(BOARD_IOID_MPU_POWER); /* Flash interface */ ti_lib_rom_ioc_pin_type_gpio_output(BOARD_IOID_FLASH_CS); ti_lib_gpio_pin_write(BOARD_FLASH_CS, 1); buzzer_init(); lpm_register_module(&sensortag_module); /* Re-enable interrupt if initially enabled. */ if(!int_disabled) { ti_lib_int_master_enable(); } }
/*---------------------------------------------------------------------------*/ void leds_arch_set(unsigned char leds) { c = leds; /* Clear everything */ ti_lib_gpio_pin_write(BOARD_LED_ALL, 0); if ((leds & LEDS_RED) == LEDS_RED) { ti_lib_gpio_pin_write(BOARD_LED_1, 1); } if ((leds & LEDS_YELLOW) == LEDS_YELLOW) { ti_lib_gpio_pin_write(BOARD_LED_2, 1); } if ((leds & LEDS_GREEN) == LEDS_GREEN) { ti_lib_gpio_pin_write(BOARD_LED_3, 1); } if ((leds & LEDS_ORANGE) == LEDS_ORANGE) { ti_lib_gpio_pin_write(BOARD_LED_4, 1); } }
/*---------------------------------------------------------------------------*/ void gpio_relay_init(void) { if(inited_relay) { return; } inited_relay = 1; ti_lib_ioc_pin_type_gpio_output(SENSOR_POWER); ti_lib_ioc_pin_type_gpio_output(ADC_CT_SELECT); ti_lib_gpio_pin_write(RELAY_ALL, 0); }
/*---------------------------------------------------------------------------*/ void leds_arch_init(void) { if(inited) { return; } inited = 1; ti_lib_ioc_pin_type_gpio_output(BOARD_IOID_LED_1); ti_lib_ioc_pin_type_gpio_output(BOARD_IOID_LED_2); ti_lib_gpio_pin_write(BOARD_LED_ALL, 0); }
/*---------------------------------------------------------------------------*/ static void configure(void) { uint32_t ctl_val = UART_CTL_UARTEN | UART_CTL_TXE; /* * Make sure the TX pin is output / high before assigning it to UART control * to avoid falling edge glitches */ ti_lib_ioc_pin_type_gpio_output(BOARD_IOID_UART_TX); ti_lib_gpio_pin_write(BOARD_UART_TX, 1); /* * Map UART signals to the correct GPIO pins and configure them as * hardware controlled. */ ti_lib_ioc_pin_type_uart(UART0_BASE, BOARD_IOID_UART_RX, BOARD_IOID_UART_TX, BOARD_IOID_UART_CTS, BOARD_IOID_UART_RTS); /* Configure the UART for 115,200, 8-N-1 operation. */ ti_lib_uart_config_set_exp_clk(UART0_BASE, ti_lib_sys_ctrl_clock_get(), CC26XX_UART_CONF_BAUD_RATE, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); /* * Generate an RX interrupt at FIFO 1/2 full. * We don't really care about the TX interrupt */ ti_lib_uart_fifo_level_set(UART0_BASE, UART_FIFO_TX7_8, UART_FIFO_RX4_8); /* Enable FIFOs */ HWREG(UART0_BASE + UART_O_LCRH) |= UART_LCRH_FEN; if(input_handler) { ctl_val += UART_CTL_RXE; } /* Enable TX, RX (conditionally), and the UART. */ HWREG(UART0_BASE + UART_O_CTL) = ctl_val; }
void adc_ct_select_set_off(void) { /* Clear everything */ ti_lib_gpio_pin_write(ADC_CT_SELECT_ENABLE, 0); }
void sensor_power_set_off(void) { /* Clear everything */ ti_lib_gpio_pin_write(SENSOR_POWER_ENABLE, 0); }
void relay_all_clear(void) { ti_lib_gpio_pin_write(RELAY_ALL, 0); }
/** * Set external flash CSN line */ static void deselect(void) { ti_lib_gpio_pin_write(BOARD_USB_CS, 1); }
/** * Clear external flash CSN line */ static void select_on_bus(void) { ti_lib_gpio_pin_write(BOARD_USB_CS, 0); }