Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ceddral7
firmware
Commits
412fc625
Commit
412fc625
authored
5 years ago
by
swym
Browse files
Options
Downloads
Patches
Plain Diff
gpio: rename constants to differentiate them from MAXIM's GPIO_ library
parent
26db6b6b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
epicardium/epicardium.h
+8
-8
8 additions, 8 deletions
epicardium/epicardium.h
epicardium/modules/gpio.c
+30
-18
30 additions, 18 deletions
epicardium/modules/gpio.c
pycardium/modules/gpio.c
+10
-8
10 additions, 8 deletions
pycardium/modules/gpio.c
with
48 additions
and
34 deletions
epicardium/epicardium.h
+
8
−
8
View file @
412fc625
...
...
@@ -427,26 +427,26 @@ API(API_BUTTONS_READ, uint8_t epic_buttons_read(uint8_t mask));
/** GPIO pins IDs */
enum
gpio_pin
{
/** ``1``, Wristband connector 1 */
GPIO_WRISTBAND_1
=
1
,
EPIC_
GPIO_WRISTBAND_1
=
1
,
/** ``2``, Wristband connector 2 */
GPIO_WRISTBAND_2
=
2
,
EPIC_
GPIO_WRISTBAND_2
=
2
,
/** ``3``, Wristband connector 3 */
GPIO_WRISTBAND_3
=
3
,
EPIC_
GPIO_WRISTBAND_3
=
3
,
/** ``4``, Wristband connector 4 */
GPIO_WRISTBAND_4
=
4
,
EPIC_
GPIO_WRISTBAND_4
=
4
,
};
/** GPIO pin modes */
enum
gpio_mode
{
/** Configure the pin as input */
GPIO_MODE_IN
=
(
1
<<
0
),
EPIC_
GPIO_MODE_IN
=
(
1
<<
0
),
/** Configure the pin as output */
GPIO_MODE_OUT
=
(
1
<<
1
),
EPIC_
GPIO_MODE_OUT
=
(
1
<<
1
),
/** Enable the internal pull-up resistor */
GPIO_PULL_UP
=
(
1
<<
6
),
EPIC_
GPIO_PULL_UP
=
(
1
<<
6
),
/** Enable the internal pull-down resistor */
GPIO_PULL_DOWN
=
(
1
<<
7
),
EPIC_
GPIO_PULL_DOWN
=
(
1
<<
7
),
};
/**
...
...
This diff is collapsed.
Click to expand it.
epicardium/modules/gpio.c
+
30
−
18
View file @
412fc625
...
...
@@ -8,36 +8,48 @@
* pins for wristband GPIO 1-4 (not 0-3 as the schematic states)
*/
static
gpio_cfg_t
gpio_configs
[]
=
{
[
GPIO_WRISTBAND_1
]
=
{
PORT_0
,
PIN_21
,
GPIO_FUNC_OUT
,
GPIO_PAD_NONE
},
[
GPIO_WRISTBAND_2
]
=
{
PORT_0
,
PIN_22
,
GPIO_FUNC_OUT
,
GPIO_PAD_NONE
},
[
GPIO_WRISTBAND_3
]
=
{
PORT_0
,
PIN_29
,
GPIO_FUNC_OUT
,
GPIO_PAD_NONE
},
[
GPIO_WRISTBAND_4
]
=
{
PORT_0
,
PIN_20
,
GPIO_FUNC_OUT
,
GPIO_PAD_NONE
},
[
EPIC_GPIO_WRISTBAND_1
]
=
{
PORT_0
,
PIN_21
,
GPIO_FUNC_OUT
,
GPIO_PAD_NONE
},
[
EPIC_GPIO_WRISTBAND_2
]
=
{
PORT_0
,
PIN_22
,
GPIO_FUNC_OUT
,
GPIO_PAD_NONE
},
[
EPIC_GPIO_WRISTBAND_3
]
=
{
PORT_0
,
PIN_29
,
GPIO_FUNC_OUT
,
GPIO_PAD_NONE
},
[
EPIC_GPIO_WRISTBAND_4
]
=
{
PORT_0
,
PIN_20
,
GPIO_FUNC_OUT
,
GPIO_PAD_NONE
},
};
int
epic_gpio_set_pin_mode
(
uint8_t
pin
,
uint8_t
mode
)
{
if
(
pin
<
GPIO_WRISTBAND_1
||
pin
>
GPIO_WRISTBAND_4
)
if
(
pin
<
EPIC_
GPIO_WRISTBAND_1
||
pin
>
EPIC_
GPIO_WRISTBAND_4
)
return
-
EINVAL
;
gpio_cfg_t
*
cfg
=
&
gpio_configs
[
pin
];
if
(
mode
&
GPIO_MODE_IN
)
{
if
(
mode
&
EPIC_
GPIO_MODE_IN
)
{
cfg
->
func
=
GPIO_FUNC_IN
;
if
(
mode
&
GPIO_MODE_OUT
)
{
if
(
mode
&
EPIC_
GPIO_MODE_OUT
)
{
return
-
EINVAL
;
}
}
else
if
(
mode
&
GPIO_MODE_OUT
)
{
}
else
if
(
mode
&
EPIC_
GPIO_MODE_OUT
)
{
cfg
->
func
=
GPIO_FUNC_OUT
;
if
(
mode
&
GPIO_MODE_IN
)
{
if
(
mode
&
EPIC_
GPIO_MODE_IN
)
{
return
-
EINVAL
;
}
}
else
{
return
-
EINVAL
;
}
if
(
mode
&
GPIO_PULL_UP
)
{
if
(
mode
&
EPIC_
GPIO_PULL_UP
)
{
cfg
->
pad
=
GPIO_PAD_PULL_UP
;
}
else
if
(
mode
&
GPIO_PULL_DOWN
)
{
}
else
if
(
mode
&
EPIC_
GPIO_PULL_DOWN
)
{
cfg
->
pad
=
GPIO_PAD_PULL_DOWN
;
}
else
{
cfg
->
pad
=
GPIO_PAD_NONE
;
...
...
@@ -50,26 +62,26 @@ int epic_gpio_set_pin_mode(uint8_t pin, uint8_t mode)
int
epic_gpio_get_pin_mode
(
uint8_t
pin
)
{
if
(
pin
<
GPIO_WRISTBAND_1
||
pin
>
GPIO_WRISTBAND_4
)
if
(
pin
<
EPIC_
GPIO_WRISTBAND_1
||
pin
>
EPIC_
GPIO_WRISTBAND_4
)
return
-
EINVAL
;
gpio_cfg_t
*
cfg
=
&
gpio_configs
[
pin
];
int
res
=
0
;
if
(
cfg
->
func
==
GPIO_FUNC_IN
)
res
|=
GPIO_MODE_IN
;
res
|=
EPIC_
GPIO_MODE_IN
;
else
if
(
cfg
->
func
==
GPIO_FUNC_OUT
)
res
|=
GPIO_MODE_OUT
;
res
|=
EPIC_
GPIO_MODE_OUT
;
if
(
cfg
->
pad
==
GPIO_PAD_PULL_UP
)
res
|=
GPIO_PULL_UP
;
res
|=
EPIC_
GPIO_PULL_UP
;
else
if
(
cfg
->
pad
==
GPIO_PAD_PULL_DOWN
)
res
|=
GPIO_PULL_DOWN
;
res
|=
EPIC_
GPIO_PULL_DOWN
;
return
res
;
}
int
epic_gpio_write_pin
(
uint8_t
pin
,
bool
on
)
{
if
(
pin
<
GPIO_WRISTBAND_1
||
pin
>
GPIO_WRISTBAND_4
)
if
(
pin
<
EPIC_
GPIO_WRISTBAND_1
||
pin
>
EPIC_
GPIO_WRISTBAND_4
)
return
-
EINVAL
;
gpio_cfg_t
*
cfg
=
&
gpio_configs
[
pin
];
...
...
@@ -86,7 +98,7 @@ int epic_gpio_write_pin(uint8_t pin, bool on)
int
epic_gpio_read_pin
(
uint8_t
pin
)
{
if
(
pin
<
GPIO_WRISTBAND_1
||
pin
>
GPIO_WRISTBAND_4
)
if
(
pin
<
EPIC_
GPIO_WRISTBAND_1
||
pin
>
EPIC_
GPIO_WRISTBAND_4
)
return
-
EINVAL
;
gpio_cfg_t
*
cfg
=
&
gpio_configs
[
pin
];
...
...
This diff is collapsed.
Click to expand it.
pycardium/modules/gpio.c
+
10
−
8
View file @
412fc625
...
...
@@ -51,11 +51,13 @@ static MP_DEFINE_CONST_FUN_OBJ_2(gpio_write, mp_gpio_write);
static
const
mp_rom_map_elem_t
gpio_module_modes_table
[]
=
{
{
MP_ROM_QSTR
(
MP_QSTR___name__
),
MP_ROM_QSTR
(
MP_QSTR_mode
)
},
{
MP_ROM_QSTR
(
MP_QSTR_INPUT
),
MP_OBJ_NEW_SMALL_INT
(
GPIO_MODE_IN
)
},
{
MP_ROM_QSTR
(
MP_QSTR_OUTPUT
),
MP_OBJ_NEW_SMALL_INT
(
GPIO_MODE_OUT
)
},
{
MP_ROM_QSTR
(
MP_QSTR_PULL_UP
),
MP_OBJ_NEW_SMALL_INT
(
GPIO_PULL_UP
)
},
{
MP_ROM_QSTR
(
MP_QSTR_INPUT
),
MP_OBJ_NEW_SMALL_INT
(
EPIC_GPIO_MODE_IN
)
},
{
MP_ROM_QSTR
(
MP_QSTR_OUTPUT
),
MP_OBJ_NEW_SMALL_INT
(
EPIC_GPIO_MODE_OUT
)
},
{
MP_ROM_QSTR
(
MP_QSTR_PULL_UP
),
MP_OBJ_NEW_SMALL_INT
(
EPIC_GPIO_PULL_UP
)
},
{
MP_ROM_QSTR
(
MP_QSTR_PULL_DOWN
),
MP_OBJ_NEW_SMALL_INT
(
GPIO_PULL_DOWN
)
},
MP_OBJ_NEW_SMALL_INT
(
EPIC_
GPIO_PULL_DOWN
)
},
};
static
MP_DEFINE_CONST_DICT
(
gpio_module_modes_dict
,
gpio_module_modes_table
);
...
...
@@ -72,13 +74,13 @@ static const mp_rom_map_elem_t gpio_module_globals_table[] = {
{
MP_ROM_QSTR
(
MP_QSTR_read
),
MP_ROM_PTR
(
&
gpio_read
)
},
{
MP_ROM_QSTR
(
MP_QSTR_write
),
MP_ROM_PTR
(
&
gpio_write
)
},
{
MP_ROM_QSTR
(
MP_QSTR_WRISTBAND_1
),
MP_OBJ_NEW_SMALL_INT
(
GPIO_WRISTBAND_1
)
},
MP_OBJ_NEW_SMALL_INT
(
EPIC_
GPIO_WRISTBAND_1
)
},
{
MP_ROM_QSTR
(
MP_QSTR_WRISTBAND_2
),
MP_OBJ_NEW_SMALL_INT
(
GPIO_WRISTBAND_2
)
},
MP_OBJ_NEW_SMALL_INT
(
EPIC_
GPIO_WRISTBAND_2
)
},
{
MP_ROM_QSTR
(
MP_QSTR_WRISTBAND_3
),
MP_OBJ_NEW_SMALL_INT
(
GPIO_WRISTBAND_3
)
},
MP_OBJ_NEW_SMALL_INT
(
EPIC_
GPIO_WRISTBAND_3
)
},
{
MP_ROM_QSTR
(
MP_QSTR_WRISTBAND_4
),
MP_OBJ_NEW_SMALL_INT
(
GPIO_WRISTBAND_4
)
},
MP_OBJ_NEW_SMALL_INT
(
EPIC_
GPIO_WRISTBAND_4
)
},
{
MP_ROM_QSTR
(
MP_QSTR_mode
),
MP_ROM_PTR
(
&
gpio_module_modes
)
},
};
static
MP_DEFINE_CONST_DICT
(
gpio_module_globals
,
gpio_module_globals_table
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment