Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
bfd22591
Commit
bfd22591
authored
Oct 29, 2019
by
f4grx
Committed by
Marcel Stör
Oct 29, 2019
Browse files
Avoid the use of invalid GPIOS when setting up a one-wire bus. (#2934)
Fixes #2933
parent
9a5327ca
Changes
1
Hide whitespace changes
Inline
Side-by-side
components/platform/onewire.c
View file @
bfd22591
...
@@ -108,6 +108,10 @@ static const uint8_t owDefaultPower = 0;
...
@@ -108,6 +108,10 @@ static const uint8_t owDefaultPower = 0;
static
int
onewire_rmt_init
(
uint8_t
gpio_num
)
static
int
onewire_rmt_init
(
uint8_t
gpio_num
)
{
{
if
(
!
GPIO_IS_VALID_GPIO
(
gpio_num
))
{
return
PLATFORM_ERR
;
}
// acquire an RMT module for TX and RX each
// acquire an RMT module for TX and RX each
if
((
ow_rmt
.
tx
=
platform_rmt_allocate
(
1
))
>=
0
)
{
if
((
ow_rmt
.
tx
=
platform_rmt_allocate
(
1
))
>=
0
)
{
if
((
ow_rmt
.
rx
=
platform_rmt_allocate
(
1
))
>=
0
)
{
if
((
ow_rmt
.
rx
=
platform_rmt_allocate
(
1
))
>=
0
)
{
...
@@ -143,6 +147,9 @@ static int onewire_rmt_init( uint8_t gpio_num )
...
@@ -143,6 +147,9 @@ static int onewire_rmt_init( uint8_t gpio_num )
if
(
rmt_driver_install
(
rmt_rx
.
channel
,
512
,
PLATFORM_RMT_INTR_FLAGS
)
==
ESP_OK
)
{
if
(
rmt_driver_install
(
rmt_rx
.
channel
,
512
,
PLATFORM_RMT_INTR_FLAGS
)
==
ESP_OK
)
{
rmt_get_ringbuf_handle
(
ow_rmt
.
rx
,
&
ow_rmt
.
rb
);
rmt_get_ringbuf_handle
(
ow_rmt
.
rx
,
&
ow_rmt
.
rb
);
#ifdef OW_DEBUG
ESP_LOGI
(
"ow"
,
"RMT RX ringbuf handle %p"
,
ow_rmt
.
rb
);
#endif
// don't set ow_rmt.gpio here
// don't set ow_rmt.gpio here
// -1 forces a full pin set procedure in first call to onewire_rmt_attach_pin()
// -1 forces a full pin set procedure in first call to onewire_rmt_attach_pin()
...
@@ -178,6 +185,10 @@ static void onewire_flush_rmt_rx_buf( void )
...
@@ -178,6 +185,10 @@ static void onewire_flush_rmt_rx_buf( void )
// check rmt TX&RX channel assignment and eventually attach them to the requested pin
// check rmt TX&RX channel assignment and eventually attach them to the requested pin
static
int
onewire_rmt_attach_pin
(
uint8_t
gpio_num
)
static
int
onewire_rmt_attach_pin
(
uint8_t
gpio_num
)
{
{
if
(
!
GPIO_IS_VALID_GPIO
(
gpio_num
))
{
return
PLATFORM_ERR
;
}
if
(
ow_rmt
.
tx
<
0
||
ow_rmt
.
rx
<
0
)
if
(
ow_rmt
.
tx
<
0
||
ow_rmt
.
rx
<
0
)
return
PLATFORM_ERR
;
return
PLATFORM_ERR
;
...
...
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