mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-07-08 02:28:58 +00:00
Configure pins for unused tag peripherals
This commit is contained in:
parent
e893c914b6
commit
2cc59c524a
@ -91,6 +91,39 @@ shutdown_handler(uint8_t mode)
|
||||
LPM_MODULE(sensortag_module, NULL, shutdown_handler, lpm_wakeup_handler,
|
||||
LPM_DOMAIN_NONE);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
configure_unused_pins(void)
|
||||
{
|
||||
/* DP[0..3] */
|
||||
ti_lib_ioc_pin_type_gpio_input(BOARD_IOID_DP0);
|
||||
ti_lib_ioc_io_port_pull_set(BOARD_IOID_DP0, IOC_IOPULL_DOWN);
|
||||
ti_lib_ioc_pin_type_gpio_input(BOARD_IOID_DP1);
|
||||
ti_lib_ioc_io_port_pull_set(BOARD_IOID_DP1, IOC_IOPULL_DOWN);
|
||||
ti_lib_ioc_pin_type_gpio_input(BOARD_IOID_DP2);
|
||||
ti_lib_ioc_io_port_pull_set(BOARD_IOID_DP2, IOC_IOPULL_DOWN);
|
||||
ti_lib_ioc_pin_type_gpio_input(BOARD_IOID_DP3);
|
||||
ti_lib_ioc_io_port_pull_set(BOARD_IOID_DP3, IOC_IOPULL_DOWN);
|
||||
|
||||
/* Devpack ID */
|
||||
ti_lib_ioc_pin_type_gpio_input(BOARD_IOID_DEVPK_ID);
|
||||
ti_lib_ioc_io_port_pull_set(BOARD_IOID_DEVPK_ID, IOC_IOPULL_UP);
|
||||
|
||||
/* Digital Microphone */
|
||||
ti_lib_ioc_pin_type_gpio_output(BOARD_IOID_MIC_POWER);
|
||||
ti_lib_gpio_pin_clear((1 << BOARD_IOID_MIC_POWER));
|
||||
ti_lib_ioc_io_drv_strength_set(BOARD_IOID_MIC_POWER, IOC_CURRENT_2MA,
|
||||
IOC_STRENGTH_MIN);
|
||||
|
||||
ti_lib_ioc_pin_type_gpio_input(BOARD_IOID_AUDIO_DI);
|
||||
ti_lib_ioc_io_port_pull_set(BOARD_IOID_AUDIO_DI, IOC_IOPULL_DOWN);
|
||||
ti_lib_ioc_pin_type_gpio_input(BOARD_IOID_AUDIO_CLK);
|
||||
ti_lib_ioc_io_port_pull_set(BOARD_IOID_AUDIO_CLK, IOC_IOPULL_DOWN);
|
||||
|
||||
/* UART over Devpack - TX only (ToDo: Map all UART pins to Debugger) */
|
||||
ti_lib_ioc_pin_type_gpio_input(BOARD_IOID_DP5_UARTTX);
|
||||
ti_lib_ioc_io_port_pull_set(BOARD_IOID_DP5_UARTTX, IOC_IOPULL_DOWN);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
board_init()
|
||||
{
|
||||
@ -113,26 +146,7 @@ board_init()
|
||||
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 */
|
||||
|
||||
/* 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);
|
||||
board_i2c_wakeup();
|
||||
|
||||
buzzer_init();
|
||||
@ -142,6 +156,9 @@ board_init()
|
||||
|
||||
lpm_register_module(&sensortag_module);
|
||||
|
||||
/* For unsupported peripherals, select a default pin configuration */
|
||||
configure_unused_pins();
|
||||
|
||||
/* Re-enable interrupt if initially enabled. */
|
||||
if(!int_disabled) {
|
||||
ti_lib_int_master_enable();
|
||||
|
@ -52,13 +52,6 @@ void
|
||||
buzzer_init()
|
||||
{
|
||||
buzzer_on = 0;
|
||||
|
||||
/* Drive the I/O ID with GPT0 / Timer A */
|
||||
ti_lib_ioc_port_configure_set(BOARD_IOID_BUZZER, IOC_PORT_MCU_PORT_EVENT0,
|
||||
IOC_STD_OUTPUT);
|
||||
|
||||
/* GPT0 / Timer A: PWM, Interrupt Enable */
|
||||
HWREG(GPT0_BASE + GPT_O_TAMR) = (TIMER_CFG_A_PWM & 0xFF) | GPT_TAMR_TAPWMIE;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
uint8_t
|
||||
@ -72,6 +65,20 @@ buzzer_start(int freq)
|
||||
{
|
||||
uint32_t load;
|
||||
|
||||
/* Enable GPT0 clocks under active, sleep, deep sleep */
|
||||
ti_lib_prcm_peripheral_run_enable(PRCM_PERIPH_TIMER0);
|
||||
ti_lib_prcm_peripheral_sleep_enable(PRCM_PERIPH_TIMER0);
|
||||
ti_lib_prcm_peripheral_deep_sleep_enable(PRCM_PERIPH_TIMER0);
|
||||
ti_lib_prcm_load_set();
|
||||
while(!ti_lib_prcm_load_get());
|
||||
|
||||
/* Drive the I/O ID with GPT0 / Timer A */
|
||||
ti_lib_ioc_port_configure_set(BOARD_IOID_BUZZER, IOC_PORT_MCU_PORT_EVENT0,
|
||||
IOC_STD_OUTPUT);
|
||||
|
||||
/* GPT0 / Timer A: PWM, Interrupt Enable */
|
||||
HWREG(GPT0_BASE + GPT_O_TAMR) = (TIMER_CFG_A_PWM & 0xFF) | GPT_TAMR_TAPWMIE;
|
||||
|
||||
buzzer_on = 1;
|
||||
|
||||
/*
|
||||
@ -93,12 +100,6 @@ buzzer_start(int freq)
|
||||
/* Start */
|
||||
ti_lib_timer_enable(GPT0_BASE, TIMER_A);
|
||||
}
|
||||
|
||||
/* Run in sleep mode */
|
||||
ti_lib_prcm_peripheral_sleep_enable(PRCM_PERIPH_TIMER0);
|
||||
ti_lib_prcm_peripheral_deep_sleep_enable(PRCM_PERIPH_TIMER0);
|
||||
ti_lib_prcm_load_set();
|
||||
while(!ti_lib_prcm_load_get());
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
@ -117,18 +118,26 @@ buzzer_stop()
|
||||
ti_lib_timer_disable(GPT0_BASE, TIMER_A);
|
||||
|
||||
/*
|
||||
* Stop running in sleep mode.
|
||||
* ToDo: Currently GPT0 is in use by clock_delay_usec (GPT0/TB) and by this
|
||||
* module here (GPT0/TA). clock_delay_usec will never need GPT0/TB in sleep
|
||||
* mode and we control TA here. Thus, with the current setup, it's OK to
|
||||
* control whether GPT0 runs in sleep mode in this module here. However, if
|
||||
* some other module at some point starts using GPT0, we should change this
|
||||
* to happen through an umbrella module
|
||||
* Stop the module clock:
|
||||
*
|
||||
* Currently GPT0 is in use by clock_delay_usec (GPT0/TB) and by this
|
||||
* module here (GPT0/TA).
|
||||
*
|
||||
* clock_delay_usec
|
||||
* - is definitely not running when we enter here and
|
||||
* - handles the module clock internally
|
||||
*
|
||||
* Thus, we can safely change the state of module clocks here.
|
||||
*/
|
||||
ti_lib_prcm_peripheral_run_disable(PRCM_PERIPH_TIMER0);
|
||||
ti_lib_prcm_peripheral_sleep_disable(PRCM_PERIPH_TIMER0);
|
||||
ti_lib_prcm_peripheral_deep_sleep_disable(PRCM_PERIPH_TIMER0);
|
||||
ti_lib_prcm_load_set();
|
||||
while(!ti_lib_prcm_load_get());
|
||||
|
||||
/* Un-configure the pin */
|
||||
ti_lib_ioc_pin_type_gpio_input(BOARD_IOID_BUZZER);
|
||||
ti_lib_ioc_io_input_set(BOARD_IOID_BUZZER, IOC_INPUT_DISABLE);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @} */
|
||||
|
Loading…
Reference in New Issue
Block a user