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
22b4c28f
Commit
22b4c28f
authored
Sep 14, 2015
by
Daniel Campora
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cc3200: New ADC API.
parent
0e52d986
Changes
7
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
370 additions
and
77 deletions
+370
-77
cc3200/boards/make-pins.py
cc3200/boards/make-pins.py
+12
-6
cc3200/mods/pybadc.c
cc3200/mods/pybadc.c
+193
-65
cc3200/mods/pybpin.c
cc3200/mods/pybpin.c
+10
-0
cc3200/mods/pybpin.h
cc3200/mods/pybpin.h
+6
-5
cc3200/qstrdefsport.h
cc3200/qstrdefsport.h
+5
-1
tests/wipy/adc.py
tests/wipy/adc.py
+116
-0
tests/wipy/adc.py.exp
tests/wipy/adc.py.exp
+28
-0
No files found.
cc3200/boards/make-pins.py
View file @
22b4c28f
...
...
@@ -35,6 +35,8 @@ class AF:
def
__init__
(
self
,
name
,
idx
,
fn
,
unit
,
type
):
self
.
name
=
name
self
.
idx
=
idx
if
self
.
idx
>
15
:
self
.
idx
=
-
1
self
.
fn
=
fn
self
.
unit
=
unit
self
.
type
=
type
...
...
@@ -57,12 +59,16 @@ class Pin:
def
print
(
self
):
print
(
'// {}'
.
format
(
self
.
name
))
if
len
(
self
.
afs
):
print
(
'const pin_af_t pin_{}_af[] = {{'
.
format
(
self
.
name
))
for
af
in
self
.
afs
:
af
.
print
()
print
(
'};'
)
print
(
'pin_obj_t pin_{:4s} = PIN({:6s}, {:1d}, {:3d}, {:2d}, pin_{}_af, {});
\n
'
.
format
(
self
.
name
,
self
.
name
,
self
.
port
,
self
.
gpio_bit
,
self
.
pin_num
,
self
.
name
,
len
(
self
.
afs
)))
else
:
print
(
'pin_obj_t pin_{:4s} = PIN({:6s}, {:1d}, {:3d}, {:2d}, NULL, 0);
\n
'
.
format
(
self
.
name
,
self
.
name
,
self
.
port
,
self
.
gpio_bit
,
self
.
pin_num
))
def
print_header
(
self
,
hdr_file
):
hdr_file
.
write
(
'extern pin_obj_t pin_{:s};
\n
'
.
format
(
self
.
name
))
...
...
cc3200/mods/pybadc.c
View file @
22b4c28f
This diff is collapsed.
Click to expand it.
cc3200/mods/pybpin.c
View file @
22b4c28f
...
...
@@ -184,6 +184,16 @@ uint8_t pin_find_peripheral_unit (const mp_obj_t pin, uint8_t fn, uint8_t type)
nlr_raise
(
mp_obj_new_exception_msg
(
&
mp_type_ValueError
,
mpexception_value_invalid_arguments
));
}
uint8_t
pin_find_peripheral_type
(
const
mp_obj_t
pin
,
uint8_t
fn
,
uint8_t
unit
)
{
pin_obj_t
*
pin_o
=
pin_find
(
pin
);
for
(
int
i
=
0
;
i
<
pin_o
->
num_afs
;
i
++
)
{
if
(
pin_o
->
af_list
[
i
].
fn
==
fn
&&
pin_o
->
af_list
[
i
].
unit
==
unit
)
{
return
pin_o
->
af_list
[
i
].
type
;
}
}
nlr_raise
(
mp_obj_new_exception_msg
(
&
mp_type_ValueError
,
mpexception_value_invalid_arguments
));
}
/******************************************************************************
DEFINE PRIVATE FUNCTIONS
******************************************************************************/
...
...
cc3200/mods/pybpin.h
View file @
22b4c28f
...
...
@@ -85,15 +85,15 @@ enum {
};
enum
{
PIN_TYPE_ADC_CH0
=
-
1
,
PIN_TYPE_ADC_CH1
=
-
1
,
PIN_TYPE_ADC_CH2
=
-
1
,
PIN_TYPE_ADC_CH3
=
-
1
,
PIN_TYPE_ADC_CH0
=
0
,
PIN_TYPE_ADC_CH1
,
PIN_TYPE_ADC_CH2
,
PIN_TYPE_ADC_CH3
,
};
typedef
struct
{
qstr
name
;
uint8_t
idx
;
int8_t
idx
;
uint8_t
fn
;
uint8_t
unit
;
uint8_t
type
;
...
...
@@ -136,5 +136,6 @@ void pin_config(pin_obj_t *self, int af, uint mode, uint type, int value, uint s
pin_obj_t
*
pin_find
(
mp_obj_t
user_obj
);
void
pin_assign_pins_af
(
mp_obj_t
*
pins
,
uint32_t
n_pins
,
uint32_t
pull
,
uint32_t
fn
,
uint32_t
unit
);
uint8_t
pin_find_peripheral_unit
(
const
mp_obj_t
pin
,
uint8_t
fn
,
uint8_t
type
);
uint8_t
pin_find_peripheral_type
(
const
mp_obj_t
pin
,
uint8_t
fn
,
uint8_t
unit
);
#endif // PYBPIN_H_
cc3200/qstrdefsport.h
View file @
22b4c28f
...
...
@@ -177,9 +177,13 @@ Q(MASTER)
// for ADC class
Q
(
ADC
)
Q
(
read
)
Q
(
ADCChannel
)
Q
(
value
)
Q
(
init
)
Q
(
deinit
)
Q
(
channel
)
Q
(
id
)
Q
(
pin
)
#if MICROPY_HW_HAS_SDCARD
// for SD class
...
...
tests/wipy/adc.py
0 → 100644
View file @
22b4c28f
'''
ADC test for the CC3200 based boards.
'''
from
pyb
import
ADC
from
pyb
import
Pin
import
os
machine
=
os
.
uname
().
machine
if
'LaunchPad'
in
machine
:
adc_pin
=
'GP5'
adc_channel
=
3
elif
'WiPy'
in
machine
:
adc_pin
=
'GP3'
adc_channel
=
1
else
:
raise
Exception
(
'Board not supported!'
)
adc
=
ADC
(
0
)
print
(
adc
)
adc
=
ADC
()
print
(
adc
)
adc
=
ADC
(
0
,
bits
=
12
)
print
(
adc
)
apin
=
adc
.
channel
(
adc_channel
)
print
(
apin
)
apin
=
adc
.
channel
(
id
=
adc_channel
)
print
(
apin
)
apin
=
adc
.
channel
(
adc_channel
,
pin
=
adc_pin
)
print
(
apin
)
apin
=
adc
.
channel
(
id
=
adc_channel
,
pin
=
adc_pin
)
print
(
apin
)
print
(
apin
.
value
()
>
3000
)
print
(
apin
()
>
3000
)
# de-init must work
apin
.
deinit
()
print
(
apin
)
adc
.
deinit
()
print
(
adc
)
print
(
apin
)
adc
.
init
()
print
(
adc
)
print
(
apin
)
apin
.
init
()
print
(
apin
)
print
(
apin
()
>
3000
)
# check for memory leaks...
for
i
in
range
(
0
,
1000
):
adc
=
ADC
()
apin
=
adc
.
channel
(
adc_channel
)
# next ones should raise
try
:
adc
=
ADC
(
bits
=
17
)
except
:
print
(
'Exception'
)
try
:
adc
=
ADC
(
id
=
1
)
except
:
print
(
'Exception'
)
try
:
adc
=
ADC
(
0
,
16
)
except
:
print
(
'Exception'
)
adc
=
ADC
()
try
:
apin
=
adc
.
channel
(
4
)
except
:
print
(
'Exception'
)
try
:
apin
=
adc
.
channel
(
-
1
)
except
:
print
(
'Exception'
)
try
:
apin
=
adc
.
channel
(
0
,
pin
=
'GP3'
)
except
:
print
(
'Exception'
)
apin
=
adc
.
channel
(
1
)
apin
.
deinit
()
try
:
apin
()
except
:
print
(
'Exception'
)
try
:
apin
.
value
()
except
:
print
(
'Exception'
)
adc
.
deinit
()
try
:
apin
.
value
()
except
:
print
(
'Exception'
)
try
:
apin
=
adc
.
channel
(
1
)
except
:
print
(
'Exception'
)
# re-init must work
adc
.
init
()
apin
.
init
()
print
(
apin
)
print
(
apin
()
>
3000
)
tests/wipy/adc.py.exp
0 → 100644
View file @
22b4c28f
ADC(0, bits=12)
ADC(0, bits=12)
ADC(0, bits=12)
ADCChannel(1, pin=GP3)
ADCChannel(1, pin=GP3)
ADCChannel(1, pin=GP3)
ADCChannel(1, pin=GP3)
True
True
ADCChannel(1)
ADC(0)
ADCChannel(1)
ADC(0, bits=12)
ADCChannel(1)
ADCChannel(1, pin=GP3)
True
Exception
Exception
Exception
Exception
Exception
Exception
Exception
Exception
Exception
Exception
ADCChannel(1, pin=GP3)
True
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