More work on GPIO reset for the RaspberryPi.
This commit is contained in:
parent
6292d3a2e7
commit
f6173c5bdc
|
@ -46,7 +46,6 @@
|
||||||
#include "osint.h"
|
#include "osint.h"
|
||||||
#ifdef RASPBERRY_PI
|
#ifdef RASPBERRY_PI
|
||||||
#include "gpio_sysfs.h"
|
#include "gpio_sysfs.h"
|
||||||
#define GPIO_PIN 17
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef int HANDLE;
|
typedef int HANDLE;
|
||||||
|
@ -54,6 +53,11 @@ static HANDLE hSerial = -1;
|
||||||
static struct termios old_sparm;
|
static struct termios old_sparm;
|
||||||
static int continue_terminal = 1;
|
static int continue_terminal = 1;
|
||||||
|
|
||||||
|
#ifdef RASPBERRY_PI
|
||||||
|
static propellerResetGpioPin = 17;
|
||||||
|
static propellerResetGpioLevel = 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Normally we use DTR for reset */
|
/* Normally we use DTR for reset */
|
||||||
static reset_method_t reset_method = RESET_WITH_DTR;
|
static reset_method_t reset_method = RESET_WITH_DTR;
|
||||||
|
|
||||||
|
@ -67,9 +71,32 @@ int use_reset_method(char* method)
|
||||||
else if (strcasecmp(method, "gpio") == 0)
|
else if (strcasecmp(method, "gpio") == 0)
|
||||||
{
|
{
|
||||||
reset_method = RESET_WITH_GPIO;
|
reset_method = RESET_WITH_GPIO;
|
||||||
gpio_export(GPIO_PIN);
|
|
||||||
gpio_write(GPIO_PIN, 0);
|
char *token;
|
||||||
gpio_direction(GPIO_PIN, 1);
|
token = strtok(method, ",");
|
||||||
|
token = strtok(NULL, ",");
|
||||||
|
if (token)
|
||||||
|
{
|
||||||
|
propellerResetGpioPin = atoi(token);
|
||||||
|
}
|
||||||
|
token = strtok(NULL, ",");
|
||||||
|
if (token)
|
||||||
|
{
|
||||||
|
propellerResetGpioLevel = atoi(token);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf ("Using GPIO pin %d as Propeller reset ", propellerResetGpioPin);
|
||||||
|
if (propellerResetGpioLevel)
|
||||||
|
{
|
||||||
|
printf ("(HIGH).\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf ("(LOW).\n");
|
||||||
|
}
|
||||||
|
gpio_export(propellerResetGpioPin);
|
||||||
|
gpio_write(propellerResetGpioPin, propellerResetGpioLevel ^ 1);
|
||||||
|
gpio_direction(propellerResetGpioPin, 1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
else {
|
else {
|
||||||
|
@ -385,7 +412,7 @@ static void assert_reset(void)
|
||||||
break;
|
break;
|
||||||
#ifdef RASPBERRY_PI
|
#ifdef RASPBERRY_PI
|
||||||
case RESET_WITH_GPIO:
|
case RESET_WITH_GPIO:
|
||||||
gpio_write(GPIO_PIN, 1);
|
gpio_write(propellerResetGpioPin, propellerResetGpioLevel);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
|
@ -414,7 +441,7 @@ static void deassert_reset(void)
|
||||||
break;
|
break;
|
||||||
#ifdef RASPBERRY_PI
|
#ifdef RASPBERRY_PI
|
||||||
case RESET_WITH_GPIO:
|
case RESET_WITH_GPIO:
|
||||||
gpio_write(GPIO_PIN, 0);
|
gpio_write(propellerResetGpioPin, propellerResetGpioLevel ^ 1);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
|
|
2
p1load.c
2
p1load.c
|
@ -157,7 +157,7 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef RASPBERRY_PI
|
#ifdef RASPBERRY_PI
|
||||||
use_reset_method("gpio");
|
use_reset_method("gpio,17,0");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
switch (InitPort(PORT_PREFIX, port, baudRate, verbose, actualPort)) {
|
switch (InitPort(PORT_PREFIX, port, baudRate, verbose, actualPort)) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user