Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
micropython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
micropython
Commits
e3f8777e
Commit
e3f8777e
authored
Aug 18, 2015
by
Daniel Campora
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cc3200: Implement new Pin API.
parent
ec8589e4
Changes
11
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
237 additions
and
187 deletions
+237
-187
cc3200/boards/cc3200_prefix.c
cc3200/boards/cc3200_prefix.c
+2
-1
cc3200/boards/make-pins.py
cc3200/boards/make-pins.py
+1
-1
cc3200/misc/mperror.c
cc3200/misc/mperror.c
+1
-1
cc3200/misc/pin_named_pins.c
cc3200/misc/pin_named_pins.c
+3
-3
cc3200/mods/pybadc.c
cc3200/mods/pybadc.c
+1
-1
cc3200/mods/pybpin.c
cc3200/mods/pybpin.c
+203
-151
cc3200/mods/pybpin.h
cc3200/mods/pybpin.h
+7
-8
cc3200/mods/pybsd.c
cc3200/mods/pybsd.c
+3
-3
cc3200/mods/pybsleep.c
cc3200/mods/pybsleep.c
+1
-1
cc3200/mptask.c
cc3200/mptask.c
+2
-2
cc3200/qstrdefsport.h
cc3200/qstrdefsport.h
+13
-15
No files found.
cc3200/boards/cc3200_prefix.c
View file @
e3f8777e
...
...
@@ -44,11 +44,12 @@
{ &pin_type }, \
.name = MP_QSTR_ ## p_pin_name, \
.port = PORT_A ## p_port, \
.
type
= PIN_TYPE_STD, \
.
pull
= PIN_TYPE_STD, \
.bit = (p_bit), \
.pin_num = (p_pin_num), \
.af = PIN_MODE_0, \
.strength = PIN_STRENGTH_4MA, \
.mode = GPIO_DIR_MODE_IN, \
.value = 0, \
.isused = false, \
}
cc3200/boards/make-pins.py
View file @
e3f8777e
...
...
@@ -107,7 +107,7 @@ class Pins(object):
for
pin
in
self
.
cpu_pins
:
if
pin
.
is_board_pin
():
pin
.
print
()
self
.
print_named
(
'
cpu
'
,
self
.
cpu_pins
)
self
.
print_named
(
'
board
'
,
self
.
cpu_pins
)
print
(
''
)
def
print_header
(
self
,
hdr_filename
):
...
...
cc3200/misc/mperror.c
View file @
e3f8777e
...
...
@@ -94,7 +94,7 @@ void mperror_init0 (void) {
MAP_GPIODirModeSet
(
MICROPY_SYS_LED_PORT
,
MICROPY_SYS_LED_PORT_PIN
,
GPIO_DIR_MODE_OUT
);
#else
// configure the system led
pin_config
((
pin_obj_t
*
)
&
MICROPY_SYS_LED_GPIO
,
PIN_MODE_0
,
GPIO_DIR_MODE_OUT
,
PIN_TYPE_STD
,
PIN_STRENGTH_6MA
);
pin_config
((
pin_obj_t
*
)
&
MICROPY_SYS_LED_GPIO
,
PIN_MODE_0
,
GPIO_DIR_MODE_OUT
,
PIN_TYPE_STD
,
0
,
PIN_STRENGTH_6MA
);
#endif
mperror_heart_beat
.
enabled
=
true
;
mperror_heartbeat_switch_off
();
...
...
cc3200/misc/pin_named_pins.c
View file @
e3f8777e
...
...
@@ -43,11 +43,11 @@ STATIC void pin_named_pins_obj_print(const mp_print_t *print, mp_obj_t self_in,
mp_printf
(
print
,
"<Pin.%q>"
,
self
->
name
);
}
const
mp_obj_type_t
pin_
cpu
_pins_obj_type
=
{
const
mp_obj_type_t
pin_
board
_pins_obj_type
=
{
{
&
mp_type_type
},
.
name
=
MP_QSTR_
cpu
,
.
name
=
MP_QSTR_
board
,
.
print
=
pin_named_pins_obj_print
,
.
locals_dict
=
(
mp_obj_t
)
&
pin_
cpu
_pins_locals_dict
,
.
locals_dict
=
(
mp_obj_t
)
&
pin_
board
_pins_locals_dict
,
};
pin_obj_t
*
pin_find_named_pin
(
const
mp_obj_dict_t
*
named_pins
,
mp_obj_t
name
)
{
...
...
cc3200/mods/pybadc.c
View file @
e3f8777e
...
...
@@ -89,7 +89,7 @@ STATIC pyb_adc_obj_t pyb_adc_obj[PYB_ADC_NUM_CHANNELS] = { {.pin = &pin_GP2, .ch
******************************************************************************/
STATIC
void
pybadc_init
(
pyb_adc_obj_t
*
self
)
{
// configure the pin in analog mode
pin_config
(
self
->
pin
,
PIN_MODE_0
,
GPIO_DIR_MODE_IN
,
PYBPIN_ANALOG_TYPE
,
PIN_STRENGTH_2MA
);
pin_config
(
self
->
pin
,
-
1
,
PIN_TYPE_ANALOG
,
PIN_TYPE_STD
,
-
1
,
PIN_STRENGTH_2MA
);
// enable the ADC channel
MAP_ADCChannelEnable
(
ADC_BASE
,
self
->
channel
);
// enable and configure the timer
...
...
cc3200/mods/pybpin.c
View file @
e3f8777e
This diff is collapsed.
Click to expand it.
cc3200/mods/pybpin.h
View file @
e3f8777e
...
...
@@ -28,8 +28,6 @@
#ifndef PYBPIN_H_
#define PYBPIN_H_
#define PYBPIN_ANALOG_TYPE 0xFF
enum
{
PORT_A0
=
GPIOA0_BASE
,
PORT_A1
=
GPIOA1_BASE
,
...
...
@@ -41,12 +39,13 @@ typedef struct {
const
mp_obj_base_t
base
;
const
qstr
name
;
const
uint32_t
port
;
uint16_t
type
;
uint16_t
pull
;
const
uint8_t
bit
;
const
uint8_t
pin_num
;
uint8_t
af
;
int8_t
af
;
uint8_t
strength
;
uint8_t
mode
;
uint8_t
mode
;
// this is now a combination of type and mode
int8_t
value
;
// -1 means no defined value
bool
isused
;
}
pin_obj_t
;
...
...
@@ -63,11 +62,11 @@ typedef struct {
const
pin_named_pin_t
*
named_pins
;
}
pin_named_pins_obj_t
;
extern
const
mp_obj_type_t
pin_
cpu
_pins_obj_type
;
extern
const
mp_obj_dict_t
pin_
cpu
_pins_locals_dict
;
extern
const
mp_obj_type_t
pin_
board
_pins_obj_type
;
extern
const
mp_obj_dict_t
pin_
board
_pins_locals_dict
;
void
pin_init0
(
void
);
void
pin_config
(
pin_obj_t
*
self
,
uint
af
,
uint
mode
,
uint
typ
e
,
uint
strength
);
void
pin_config
(
pin_obj_t
*
self
,
int
af
,
uint
mode
,
uint
type
,
int
valu
e
,
uint
strength
);
pin_obj_t
*
pin_find
(
mp_obj_t
user_obj
);
pin_obj_t
*
pin_find_named_pin
(
const
mp_obj_dict_t
*
named_pins
,
mp_obj_t
name
);
pin_obj_t
*
pin_find_pin_by_port_bit
(
const
mp_obj_dict_t
*
named_pins
,
uint
port
,
uint
bit
);
...
...
cc3200/mods/pybsd.c
View file @
e3f8777e
...
...
@@ -122,11 +122,11 @@ STATIC mp_obj_t pybsd_init_helper (pybsd_obj_t *self, uint n_args, const mp_obj_
self
->
pin_clk
=
(
pin_obj_t
*
)
pin_find
(
items
[
2
]);
// configure the data pin with pull-up enabled
pin_config
((
pin_obj_t
*
)
pin_find
(
items
[
0
]),
mp_obj_get_int
(
items
[
1
]),
0
,
PIN_TYPE_STD_PU
,
PIN_STRENGTH_4MA
);
pin_config
((
pin_obj_t
*
)
pin_find
(
items
[
0
]),
mp_obj_get_int
(
items
[
1
]),
0
,
PIN_TYPE_STD_PU
,
-
1
,
PIN_STRENGTH_4MA
);
// configure the clock pin
pin_config
(
self
->
pin_clk
,
mp_obj_get_int
(
items
[
3
]),
0
,
PIN_TYPE_STD
,
PIN_STRENGTH_4MA
);
pin_config
(
self
->
pin_clk
,
mp_obj_get_int
(
items
[
3
]),
0
,
PIN_TYPE_STD
,
-
1
,
PIN_STRENGTH_4MA
);
// configure the command pin with pull-up enabled
pin_config
((
pin_obj_t
*
)
pin_find
(
items
[
4
]),
mp_obj_get_int
(
items
[
5
]),
0
,
PIN_TYPE_STD_PU
,
PIN_STRENGTH_4MA
);
pin_config
((
pin_obj_t
*
)
pin_find
(
items
[
4
]),
mp_obj_get_int
(
items
[
5
]),
0
,
PIN_TYPE_STD_PU
,
-
1
,
PIN_STRENGTH_4MA
);
self
->
pinsset
=
true
;
}
else
{
nlr_raise
(
mp_obj_new_exception_msg
(
&
mp_type_TypeError
,
mpexception_num_type_invalid_arguments
));
...
...
cc3200/mods/pybsleep.c
View file @
e3f8777e
...
...
@@ -460,7 +460,7 @@ STATIC void pybsleep_obj_wakeup (void) {
}
STATIC
void
pybsleep_iopark
(
bool
hibernate
)
{
mp_map_t
*
named_map
=
mp_obj_dict_get_map
((
mp_obj_t
)
&
pin_
cpu
_pins_locals_dict
);
mp_map_t
*
named_map
=
mp_obj_dict_get_map
((
mp_obj_t
)
&
pin_
board
_pins_locals_dict
);
for
(
uint
i
=
0
;
i
<
named_map
->
used
;
i
++
)
{
pin_obj_t
*
pin
=
(
pin_obj_t
*
)
named_map
->
table
[
i
].
value
;
switch
(
pin
->
pin_num
)
{
...
...
cc3200/mptask.c
View file @
e3f8777e
...
...
@@ -141,8 +141,8 @@ soft_reset:
#ifdef LAUNCHXL
// configure the stdio uart pins with the correct alternate functions
// param 3 ("mode") is DON'T CARE" for AFs others than GPIO
pin_config
((
pin_obj_t
*
)
&
MICROPY_STDIO_UART_TX_PIN
,
MICROPY_STDIO_UART_TX_PIN_AF
,
0
,
PIN_TYPE_STD_PU
,
PIN_STRENGTH_2MA
);
pin_config
((
pin_obj_t
*
)
&
MICROPY_STDIO_UART_RX_PIN
,
MICROPY_STDIO_UART_RX_PIN_AF
,
0
,
PIN_TYPE_STD_PU
,
PIN_STRENGTH_2MA
);
pin_config
((
pin_obj_t
*
)
&
MICROPY_STDIO_UART_TX_PIN
,
MICROPY_STDIO_UART_TX_PIN_AF
,
0
,
PIN_TYPE_STD_PU
,
-
1
,
PIN_STRENGTH_2MA
);
pin_config
((
pin_obj_t
*
)
&
MICROPY_STDIO_UART_RX_PIN
,
MICROPY_STDIO_UART_RX_PIN_AF
,
0
,
PIN_TYPE_STD_PU
,
-
1
,
PIN_STRENGTH_2MA
);
// instantiate the stdio uart
mp_obj_t
args
[
2
]
=
{
mp_obj_new_int
(
MICROPY_STDIO_UART
),
...
...
cc3200/qstrdefsport.h
View file @
e3f8777e
...
...
@@ -110,34 +110,32 @@ Q(tell)
// for Pin class
Q
(
Pin
)
Q
(
cpu
)
Q
(
board
)
Q
(
init
)
Q
(
value
)
Q
(
low
)
Q
(
high
)
Q
(
toggle
)
Q
(
info
)
Q
(
name
)
Q
(
af
)
Q
(
id
)
Q
(
mode
)
Q
(
type
)
Q
(
strength
)
Q
(
pull
)
Q
(
drive
)
Q
(
IN
)
Q
(
OUT
)
Q
(
STD
)
Q
(
STD_PU
)
Q
(
STD_PD
)
Q
(
OD
)
Q
(
OD_PU
)
Q
(
OD_PD
)
Q
(
OPEN_DRAIN
)
Q
(
ALT
)
Q
(
ALT_OPEN_DRAIN
)
Q
(
PULL_UP
)
Q
(
PULL_DOWN
)
Q
(
PULL_NONE
)
Q
(
LOW_POWER
)
Q
(
MED_POWER
)
Q
(
HIGH_POWER
)
Q
(
INT_RISING
)
Q
(
INT_FALLING
)
Q
(
INT_RISING_FALLING
)
Q
(
INT_LOW_LEVEL
)
Q
(
INT_HIGH_LEVEL
)
Q
(
S2MA
)
Q
(
S4MA
)
Q
(
S6MA
)
// for UART class
Q
(
UART
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment