mirror of
https://github.com/espruino/Espruino.git
synced 2025-12-08 19:06:15 +00:00
Get Onewire working, support pin.toggle()
This commit is contained in:
parent
6cca0fc1b9
commit
6bcdb05e4b
@ -22,6 +22,7 @@
|
||||
* of the Espruino environment and can not be changed without express
|
||||
* approval from all the stakeholders. In addition, the semantics of the
|
||||
* functions should follow the expected conventions.
|
||||
* functions should follow the expected conventions.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
|
||||
@ -200,6 +201,7 @@ bool jshSleep(JsSysTime timeUntilWake) {
|
||||
*/
|
||||
void jshDelayMicroseconds(int microsec) {
|
||||
ets_delay_us(microsec);
|
||||
//vTaskDelay(microsec / portTICK_PERIOD_MS / 1000);
|
||||
} // End of jshDelayMicroseconds
|
||||
|
||||
|
||||
@ -235,7 +237,7 @@ void jshPinSetState(
|
||||
gpio_pull_mode_t pull_mode=GPIO_FLOATING;
|
||||
switch(state) {
|
||||
case JSHPINSTATE_GPIO_OUT:
|
||||
mode = GPIO_MODE_OUTPUT;
|
||||
mode = GPIO_MODE_INPUT_OUTPUT;
|
||||
break;
|
||||
case JSHPINSTATE_GPIO_IN:
|
||||
mode = GPIO_MODE_INPUT;
|
||||
@ -249,10 +251,10 @@ void jshPinSetState(
|
||||
pull_mode=GPIO_PULLDOWN_ONLY;
|
||||
break;
|
||||
case JSHPINSTATE_GPIO_OUT_OPENDRAIN:
|
||||
mode = GPIO_MODE_OUTPUT_OD;
|
||||
mode = GPIO_MODE_INPUT_OUTPUT_OD;
|
||||
break;
|
||||
case JSHPINSTATE_GPIO_OUT_OPENDRAIN_PULLUP:
|
||||
mode = GPIO_MODE_OUTPUT_OD;
|
||||
mode = GPIO_MODE_INPUT_OUTPUT_OD;
|
||||
pull_mode=GPIO_PULLUP_ONLY;
|
||||
break;
|
||||
default:
|
||||
@ -272,6 +274,8 @@ void jshPinSetState(
|
||||
* \return The current state of the selected pin.
|
||||
*/
|
||||
JshPinState jshPinGetState(Pin pin) {
|
||||
if ( jshPinGetValue(pin) & 1 )
|
||||
return g_pinState[pin] | JSHPINSTATE_PIN_IS_ON;
|
||||
return g_pinState[pin];
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user