Commit f41a61d1 authored by François Revol's avatar François Revol

Expose the IR LED GPIO to python

This might be needed for useless stuff like turning off TVs.
parent b6832e3f
......@@ -496,6 +496,8 @@ enum gpio_pin {
EPIC_GPIO_WRISTBAND_3 = 3,
/** ``4``, Wristband connector 4 */
EPIC_GPIO_WRISTBAND_4 = 4,
/** ``5``, IR LED */
EPIC_GPIO_IR_LED = 5,
};
/** GPIO pin modes */
......
......@@ -28,6 +28,10 @@ gpio_cfg_t gpio_configs[] = {
PIN_20,
GPIO_FUNC_OUT,
GPIO_PAD_NONE },
[EPIC_GPIO_IR_LED] = { PORT_0,
PIN_23,
GPIO_FUNC_OUT,
GPIO_PAD_NONE },
};
static int s_adc_channels[] = {
......@@ -39,11 +43,12 @@ static int s_adc_channels[] = {
*/
[EPIC_GPIO_WRISTBAND_3] = -1,
[EPIC_GPIO_WRISTBAND_4] = ADC_CH_4,
[EPIC_GPIO_IR_LED] = ADC_CH_7,
};
int epic_gpio_set_pin_mode(uint8_t pin, uint8_t mode)
{
if (pin < EPIC_GPIO_WRISTBAND_1 || pin > EPIC_GPIO_WRISTBAND_4)
if (pin < EPIC_GPIO_WRISTBAND_1 || pin > EPIC_GPIO_IR_LED)
return -EINVAL;
gpio_cfg_t *cfg = &gpio_configs[pin];
......@@ -90,7 +95,7 @@ int epic_gpio_set_pin_mode(uint8_t pin, uint8_t mode)
int epic_gpio_get_pin_mode(uint8_t pin)
{
if (pin < EPIC_GPIO_WRISTBAND_1 || pin > EPIC_GPIO_WRISTBAND_4)
if (pin < EPIC_GPIO_WRISTBAND_1 || pin > EPIC_GPIO_IR_LED)
return -EINVAL;
gpio_cfg_t *cfg = &gpio_configs[pin];
......@@ -111,7 +116,7 @@ int epic_gpio_get_pin_mode(uint8_t pin)
int epic_gpio_write_pin(uint8_t pin, bool on)
{
if (pin < EPIC_GPIO_WRISTBAND_1 || pin > EPIC_GPIO_WRISTBAND_4)
if (pin < EPIC_GPIO_WRISTBAND_1 || pin > EPIC_GPIO_IR_LED)
return -EINVAL;
gpio_cfg_t *cfg = &gpio_configs[pin];
......@@ -128,7 +133,7 @@ int epic_gpio_write_pin(uint8_t pin, bool on)
int epic_gpio_read_pin(uint8_t pin)
{
if (pin < EPIC_GPIO_WRISTBAND_1 || pin > EPIC_GPIO_WRISTBAND_4)
if (pin < EPIC_GPIO_WRISTBAND_1 || pin > EPIC_GPIO_IR_LED)
return -EINVAL;
gpio_cfg_t *cfg = &gpio_configs[pin];
......
......@@ -82,6 +82,8 @@ static const mp_rom_map_elem_t gpio_module_globals_table[] = {
MP_OBJ_NEW_SMALL_INT(EPIC_GPIO_WRISTBAND_3) },
{ MP_ROM_QSTR(MP_QSTR_WRISTBAND_4),
MP_OBJ_NEW_SMALL_INT(EPIC_GPIO_WRISTBAND_4) },
{ MP_ROM_QSTR(MP_QSTR_IR_LED),
MP_OBJ_NEW_SMALL_INT(EPIC_GPIO_IR_LED) },
{ MP_ROM_QSTR(MP_QSTR_mode), MP_ROM_PTR(&gpio_module_modes) },
};
static MP_DEFINE_CONST_DICT(gpio_module_globals, gpio_module_globals_table);
......
......@@ -163,6 +163,7 @@ Q(WRISTBAND_1)
Q(WRISTBAND_2)
Q(WRISTBAND_3)
Q(WRISTBAND_4)
Q(IR_LED)
Q(INPUT)
Q(OUTPUT)
Q(ADC)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment