From: John Melton - G0ORX Date: Fri, 27 Oct 2017 16:13:49 +0000 (+0000) Subject: updated gpio to use wiringPi rather than pigpio so will work on Tinker board as well... X-Git-Url: https://git.rkrishnan.org/pf/$rel_link?a=commitdiff_plain;h=7d526c664e2b8f0874ef5448721dcbe14415bc64;p=pihpsdr.git updated gpio to use wiringPi rather than pigpio so will work on Tinker board as well as Raspberry Pi --- diff --git a/Makefile b/Makefile index 4799d1b..91e27b2 100644 --- a/Makefile +++ b/Makefile @@ -127,7 +127,7 @@ endif ifeq ($(GPIO_INCLUDE),GPIO) GPIO_OPTIONS=-D GPIO - GPIO_LIBS=-lwiringPi -lpigpio + GPIO_LIBS=-lwiringPi GPIO_SOURCES= \ gpio.c \ encoder_menu.c diff --git a/discovery.c b/discovery.c index fa46f02..95baeb3 100644 --- a/discovery.c +++ b/discovery.c @@ -144,14 +144,20 @@ fprintf(stderr,"discovery\n"); GtkWidget *label=gtk_label_new("No devices found!"); gtk_grid_attach(GTK_GRID(grid),label,0,0,2,1); - GtkWidget *exit_b=gtk_button_new_with_label("Exit"); - g_signal_connect (exit_b, "button-press-event", G_CALLBACK(exit_cb), NULL); - gtk_grid_attach(GTK_GRID(grid),exit_b,0,1,1,1); +#ifdef GPIO + GtkWidget *gpio_b=gtk_button_new_with_label("Config GPIO"); + g_signal_connect (gpio_b, "button-press-event", G_CALLBACK(gpio_cb), NULL); + gtk_grid_attach(GTK_GRID(grid),gpio_b,0,1,1,1); +#endif GtkWidget *discover_b=gtk_button_new_with_label("Retry Discovery"); g_signal_connect (discover_b, "button-press-event", G_CALLBACK(discover_cb), NULL); gtk_grid_attach(GTK_GRID(grid),discover_b,1,1,1,1); + GtkWidget *exit_b=gtk_button_new_with_label("Exit"); + g_signal_connect (exit_b, "button-press-event", G_CALLBACK(exit_cb), NULL); + gtk_grid_attach(GTK_GRID(grid),exit_b,2,1,1,1); + gtk_container_add (GTK_CONTAINER (content), grid); gtk_widget_show_all(discovery_dialog); } else { diff --git a/gpio.c b/gpio.c index d3ec303..67c756f 100644 --- a/gpio.c +++ b/gpio.c @@ -1,6 +1,24 @@ +/* Copyright (C) +* 2015 - John Melton, G0ORX/N6LYT +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +* +*/ + #include -#ifdef GPIO #include #include #include @@ -10,15 +28,8 @@ #include #include #include -//#include #include #include -#ifdef GPIO -#include -#endif -#ifdef sx1509 -#include -#endif #include "band.h" #include "channel.h" @@ -39,9 +50,61 @@ #endif #include "new_menu.h" #include "encoder_menu.h" +#include "gpio.h" +#ifdef I2C +#include "i2c.h" +#endif + +// debounce settle time in us +#define SETTLE_TIME 100000 + +// uses wiringpi pin numbers +int ENABLE_VFO_ENCODER=1; +int ENABLE_VFO_PULLUP=1; +int VFO_ENCODER_A=1; +int VFO_ENCODER_B=0; +int ENABLE_E1_ENCODER=1; +int ENABLE_E1_PULLUP=0; +int E1_ENCODER_A=28; +int E1_ENCODER_B=25; +int E1_FUNCTION=6; +int ENABLE_E2_ENCODER=1; +int ENABLE_E2_PULLUP=0; +int E2_ENCODER_A=27; +int E2_ENCODER_B=24; +int E2_FUNCTION=10; +int ENABLE_E3_ENCODER=1; +int ENABLE_E3_PULLUP=0; +int E3_ENCODER_A=7; +int E3_ENCODER_B=29; +int E3_FUNCTION=11; +int ENABLE_S1_BUTTON=1; +int S1_BUTTON=23; +int ENABLE_S2_BUTTON=1; +int S2_BUTTON=26; +int ENABLE_S3_BUTTON=1; +int S3_BUTTON=22; +int ENABLE_S4_BUTTON=1; +int S4_BUTTON=21; +int ENABLE_S5_BUTTON=1; +int S5_BUTTON=5; +int ENABLE_S6_BUTTON=1; +int S6_BUTTON=4; +int ENABLE_MOX_BUTTON=1; +int MOX_BUTTON=2; +int ENABLE_FUNCTION_BUTTON=1; +int FUNCTION_BUTTON=3; +int ENABLE_E1_BUTTON=1; +int ENABLE_E2_BUTTON=1; +int ENABLE_E3_BUTTON=1; +int ENABLE_CW_BUTTONS=1; -#define SYSFS_GPIO_DIR "/sys/class/gpio" +#ifdef I2C +int I2C_INTERRUPT=15; +#endif +/* +// uses broadcom pin numbers -- not working on Tinker board int ENABLE_VFO_ENCODER=1; int ENABLE_VFO_PULLUP=1; int VFO_ENCODER_A=18; @@ -98,64 +161,7 @@ int ENABLE_CW_BUTTONS=1; int CWL_BUTTON=9; int CWR_BUTTON=10; #endif - -#ifdef sx1509 -/* Hardware Hookup: - -Leaves a spare gpio and an extra unused button (x1) - -SX1509 Breakout ------ Odroid ------------ Component - GND -------------- GND (1) - 3V3 -------------- 3.3V(6) - SDA -------------- SDA (3) - SCL -------------- SCL (5) - INT -------------- #88 (11) - 0 --------------------------------- TN S1 E1 (row 1) - 1 --------------------------------- S2 S3 E2 (row 2) - 2 --------------------------------- S4 S5 E3 (row 3) - 3 --------------------------------- S6 FN x1 (row 4) - 4 --------------------------------- VFO_ENCODER_A - 5 --------------------------------- VFO_ENCODER_B - 6 --------------------------------- E1_ENCODER_A - 7 --------------------------------- E1_ENCODER_B - 8 --------------------------------- TN S2 S4 S6 (col 1) - 9 --------------------------------- S1 S3 S5 FN (col 2) - 10 -------------------------------- E1 E2 E3 x1 (col 3) - 11 -------------------------------- E2_ENCODER_A - 12 -------------------------------- E2_ENCODER_B - 13 -------------------------------- E3_ENCODER_A - 14 -------------------------------- E3_ENCODER_B - 15 -------------------------------- spare_gpio - -Alternate to allow 5 extra buttons - - 0 --------------------------------- TN S1 x1 x2 (row 1) - 1 --------------------------------- S2 S3 E1 x4 (row 2) - 2 --------------------------------- S4 S5 E2 x5 (row 3) - 3 --------------------------------- S6 x3 E3 FN (row 4) - 4 --------------------------------- VFO_ENCODER_A - 5 --------------------------------- VFO_ENCODER_B - 6 --------------------------------- E1_ENCODER_A - 7 --------------------------------- E1_ENCODER_B - 8 --------------------------------- TN S2 S4 S6 (col 1) - 9 --------------------------------- S1 S3 S5 x3 (col 2) - 10 -------------------------------- x1 E1 E2 E3 (col 3) - 11 -------------------------------- x2 x4 x5 FN (col 4) - 12 -------------------------------- E2_ENCODER_A - 13 -------------------------------- E2_ENCODER_B - 14 -------------------------------- E3_ENCODER_A - 15 -------------------------------- E3_ENCODER_B - -x1-x5 (spare buttons) - */ -const uint8_t SX1509_ADDRESS=0x3E; -struct SX1509* pSX1509; - -//#ifdef odroid -int SX1509_INT_PIN=0; -//#endif -#endif static volatile int vfoEncoderPos; static volatile int e1EncoderPos; @@ -177,10 +183,9 @@ static volatile int agc_state; static volatile int mox_state; static volatile int lock_state; -//static void* rotary_encoder_thread(void *arg); static gpointer rotary_encoder_thread(gpointer data); -//static pthread_t rotary_encoder_thread_id; static GThread *rotary_encoder_thread_id; + static int previous_function_button=0; static int e1_function=0; static int previous_e1_function=0; @@ -203,7 +208,6 @@ static int previous_agc_button=0; static int mox_button=0; static int previous_mox_button=0; -//static GMutex m_running; static int running=0; char *encoder_string[] = { @@ -212,12 +216,11 @@ char *encoder_string[] = { "ATTENUATION", "MIC GAIN", "DRIVE", -"TUNE DRIVE", "RIT", "CW SPEED", "CW FREQUENCY", "PANADAPTER HIGH", -"PANADAPTER LOW", +"PANADAPTER LOW" }; static int mox_pressed(void *data) { @@ -296,97 +299,111 @@ static int e_function_pressed(void *data) { return 0; } -static void e1FunctionAlert(int gpio, int level, uint32_t tick) { +static void e1FunctionAlert() { + int level=digitalRead(E1_FUNCTION); if(level==0) { if(running) g_idle_add(e_function_pressed,(gpointer)1); } + usleep(SETTLE_TIME); } -static void e2FunctionAlert(int gpio, int level, uint32_t tick) { +static void e2FunctionAlert() { + int level=digitalRead(E2_FUNCTION); if(level==0) { if(running) g_idle_add(e_function_pressed,(gpointer)2); } + usleep(SETTLE_TIME); } -static void e3FunctionAlert(int gpio, int level, uint32_t tick) { +static void e3FunctionAlert() { + int level=digitalRead(E3_FUNCTION); if(level==0) { if(running) g_idle_add(e_function_pressed,(gpointer)3); } + usleep(SETTLE_TIME); } -static void functionAlert(int gpio, int level, uint32_t tick) { +static void functionAlert() { + int level=digitalRead(FUNCTION_BUTTON); if(level==0) { if(running) g_idle_add(function_pressed,NULL); } + usleep(SETTLE_TIME); } - -static void s1Alert(int gpio, int level, uint32_t tick) { +static void s1Alert() { + int level=digitalRead(S1_BUTTON); if(level==0) { g_idle_add(s1_pressed,NULL); } else { g_idle_add(s1_released,NULL); } + usleep(SETTLE_TIME); } -static void s2Alert(int gpio, int level, uint32_t tick) { +static void s2Alert() { + int level=digitalRead(S2_BUTTON); if(level==0) { g_idle_add(s2_pressed,NULL); } else { g_idle_add(s2_released,NULL); } + usleep(SETTLE_TIME); } -static void s3Alert(int gpio, int level, uint32_t tick) { +static void s3Alert() { + int level=digitalRead(S3_BUTTON); if(level==0) { g_idle_add(s3_pressed,NULL); } else { g_idle_add(s3_released,NULL); } + usleep(SETTLE_TIME); } -static void s4Alert(int gpio, int level, uint32_t tick) { +static void s4Alert() { + int level=digitalRead(S4_BUTTON); if(level==0) { g_idle_add(s4_pressed,NULL); } else { g_idle_add(s4_released,NULL); } + usleep(SETTLE_TIME); } -static void s5Alert(int gpio, int level, uint32_t tick) { +static void s5Alert() { + int level=digitalRead(S5_BUTTON); if(level==0) { g_idle_add(s5_pressed,NULL); } else { g_idle_add(s5_released,NULL); } + usleep(SETTLE_TIME); } -static void s6Alert(int gpio, int level, uint32_t tick) { +static void s6Alert() { + int level=digitalRead(S6_BUTTON); if(level==0) { g_idle_add(s6_pressed,NULL); } else { g_idle_add(s6_released,NULL); } + usleep(SETTLE_TIME); } -static void moxAlert(int gpio, int level, uint32_t tick) { - if(level==0) { +static unsigned long moxdebounce=0; + +static void moxAlert() { + int level1=digitalRead(MOX_BUTTON); + usleep(20000); + int level2=digitalRead(MOX_BUTTON); +fprintf(stderr,"moxAlert: level1=%d level2=%d\n",level1,level2); + if(level1==0 && level2==0) { g_idle_add(mox_pressed,(gpointer)NULL); - } else { } + usleep(SETTLE_TIME); } -static void lockAlert(int gpio, int level, uint32_t tick) { - lock_state=(level==0); -} - -#ifdef LOCALCW -static void cwAlert(int gpio, int level, uint32_t tick) { - if (cw_keyer_internal == 0 && (mode==modeCWL || mode==modeCWU)) - keyer_event(gpio, cw_active_level == 0 ? level : (level==0)); -} -#endif - static void vfoEncoderPulse(int gpio, int level, unsigned int tick) { static int levA=0, levB=0, lastGpio = -1; @@ -407,136 +424,113 @@ static void vfoEncoderPulse(int gpio, int level, unsigned int tick) { } } -static void e1EncoderPulse(int gpio, int level, uint32_t tick) -{ - static int levA=0, levB=0, lastGpio = -1; +static void vfoEncoderA() { + int level=digitalRead(VFO_ENCODER_A); + vfoEncoderPulse(VFO_ENCODER_A,level,0); +} - if (gpio == E1_ENCODER_A) levA = level; else levB = level; +static void vfoEncoderB() { + int level=digitalRead(VFO_ENCODER_B); + vfoEncoderPulse(VFO_ENCODER_B,level,0); +} - if (gpio != lastGpio) /* debounce */ - { - lastGpio = gpio; +static void e1EncoderInterrupt(int gpio) { + static int e1CurrentA=1, e1CurrentB=1; - if ((gpio == E1_ENCODER_A) && (level == 0)) - { - if (!levB) ++e1EncoderPos; - } - else if ((gpio == E1_ENCODER_B) && (level == 1)) - { - if (levA) --e1EncoderPos; - } - } -} + int levelA=digitalRead(E1_ENCODER_A); + int levelB=digitalRead(E1_ENCODER_B); -static void e2EncoderPulse(int gpio, int level, uint32_t tick) -{ - static int levA=0, levB=0, lastGpio = -1; + if(e1CurrentA==levelA && e1CurrentB==levelB) { + return; + } - if (gpio == E2_ENCODER_A) levA = level; else levB = level; + e1CurrentA=levelA; + e1CurrentB=levelB; - if (gpio != lastGpio) /* debounce */ - { - lastGpio = gpio; + if(levelA && levelB) { + if(gpio==E1_ENCODER_B) { + --e1EncoderPos; + } else { + ++e1EncoderPos; + } + } +} - if ((gpio == E2_ENCODER_A) && (level == 0)) - { - if (!levB) ++e2EncoderPos; - } - else if ((gpio == E2_ENCODER_B) && (level == 1)) - { - if (levA) --e2EncoderPos; - } - } +static void e1EncoderA() { + e1EncoderInterrupt(E1_ENCODER_A); } -static void e3EncoderPulse(int gpio, int level, uint32_t tick) -{ - static int levA=0, levB=0, lastGpio = -1; +static void e1EncoderB() { + e1EncoderInterrupt(E1_ENCODER_B); +} - if (gpio == E3_ENCODER_A) levA = level; else levB = level; +static void e2EncoderInterrupt(int gpio) { + static int e2CurrentA=1, e2CurrentB=1; - if (gpio != lastGpio) /* debounce */ - { - lastGpio = gpio; + int levelA=digitalRead(E2_ENCODER_A); + int levelB=digitalRead(E2_ENCODER_B); - if ((gpio == E3_ENCODER_A) && (level == 0)) - { - if (!levB) ++e3EncoderPos; - } - else if ((gpio == E3_ENCODER_B) && (level == 1)) - { - if (levA) --e3EncoderPos; - } - } + if(e2CurrentA==levelA && e2CurrentB==levelB) { + return; + } + + e2CurrentA=levelA; + e2CurrentB=levelB; + + if(levelA && levelB) { + if(gpio==E2_ENCODER_B) { + --e2EncoderPos; + } else { + ++e2EncoderPos; + } + } } -#ifdef sx1509 -#define SX1509_ENCODER_MASK 0xF0F0 +static void e2EncoderA() { + e2EncoderInterrupt(E2_ENCODER_A); +} -#define BTN_ROWS 4 // Number of rows in the button matrix -#define BTN_COLS 4 // Number of columns in the button matrix +static void e2EncoderB() { + e2EncoderInterrupt(E2_ENCODER_B); +} -// btnMap maps row/column combinations to button states: -volatile int *btnArray[BTN_ROWS][BTN_COLS] = { - { &mox_state, &band_state, NULL, NULL}, - { &bandstack_state, &mode_state, &e1Function, NULL}, - { &filter_state, &noise_state, &e2Function, NULL}, - { &agc_state, NULL, &e3Function, &function_state} -}; +static void e3EncoderInterrupt(int gpio) { + static int e3CurrentA=1, e3CurrentB=1; -void sx1509_interrupt(void) { - - static int lastBtnPress = 255; - static uint64_t lastBtnPressTime = 0; - - // read and clear encoder interrupts - uint16_t encInterrupt = SX1509_interruptSource(pSX1509, true); - - - if (encInterrupt & SX1509_ENCODER_MASK) { - if (encInterrupt & (1<) to initialize the SX1509. If it - // successfully communicates, it'll return 1. 255 for soft reset - if (!SX1509_begin(pSX1509, SX1509_ADDRESS, 255)) - { - printf("Failed to communicate to sx1509 at %x.\n", SX1509_ADDRESS); - return 1; + if(ENABLE_S3_BUTTON) { + setup_pin(S3_BUTTON, PUD_UP, &s3Alert); } - fprintf(stderr,"wiringPiSetup\n"); - if (wiringPiSetup () < 0) { - printf ("Unable to setup wiringPi: %s\n", strerror (errno)); - return 1; + if(ENABLE_S4_BUTTON) { + setup_pin(S4_BUTTON, PUD_UP, &s4Alert); } - // Initialize the buttons - // Sleep time off (0). 16ms scan time, 8ms debounce: - SX1509_keypad(pSX1509, BTN_ROWS, BTN_COLS, 0, 16, 8); - - // Initialize the encoders - SX1509_pinMode(pSX1509, VFO_ENCODER_A, INPUT_PULLUP); - SX1509_pinMode(pSX1509, VFO_ENCODER_B, INPUT_PULLUP); - SX1509_enableInterrupt(pSX1509, VFO_ENCODER_A, CHANGE); - SX1509_enableInterrupt(pSX1509, VFO_ENCODER_B, CHANGE); - vfoEncoderPos=0; - SX1509_pinMode(pSX1509, E1_ENCODER_A, INPUT_PULLUP); - SX1509_pinMode(pSX1509, E1_ENCODER_B, INPUT_PULLUP); - SX1509_enableInterrupt(pSX1509, E1_ENCODER_A, CHANGE); - SX1509_enableInterrupt(pSX1509, E1_ENCODER_B, CHANGE); - e1EncoderPos=0; - SX1509_pinMode(pSX1509, E2_ENCODER_A, INPUT_PULLUP); - SX1509_pinMode(pSX1509, E2_ENCODER_B, INPUT_PULLUP); - SX1509_enableInterrupt(pSX1509, E2_ENCODER_A, CHANGE); - SX1509_enableInterrupt(pSX1509, E2_ENCODER_B, CHANGE); - e2EncoderPos=0; - SX1509_pinMode(pSX1509, E3_ENCODER_A, INPUT_PULLUP); - SX1509_pinMode(pSX1509, E3_ENCODER_B, INPUT_PULLUP); - SX1509_enableInterrupt(pSX1509, E3_ENCODER_A, CHANGE); - SX1509_enableInterrupt(pSX1509, E3_ENCODER_B, CHANGE); - e3EncoderPos=0; - - e1Function=0; - e2Function=0; - e3Function=0; - - pinMode(SX1509_INT_PIN, INPUT); - pullUpDnControl(SX1509_INT_PIN, PUD_UP); - - if ( wiringPiISR (SX1509_INT_PIN, INT_EDGE_FALLING, &sx1509_interrupt) < 0 ) { - printf ("Unable to setup ISR: %s\n", strerror (errno)); - return 1; + if(ENABLE_S5_BUTTON) { + setup_pin(S5_BUTTON, PUD_UP, &s5Alert); } -#endif - -#if defined odroid && !defined sx1509 - //VFO_ENCODER_A=ODROID_VFO_ENCODER_A; - //VFO_ENCODER_B=ODROID_VFO_ENCODER_B; - //VFO_ENCODER_A_PIN=ODROID_VFO_ENCODER_A_PIN; - //VFO_ENCODER_B_PIN=ODROID_VFO_ENCODER_B_PIN; - - fprintf(stderr,"gpio_init: VFO_ENCODER_A=%d VFO_ENCODER_B=%d\n",VFO_ENCODER_A,VFO_ENCODER_B); - - fprintf(stderr,"wiringPiSetup\n"); - if (wiringPiSetup () < 0) { - printf ("Unable to setup wiringPi: %s\n", strerror (errno)); - return -1; - } - - FILE *fp; - - fp = popen("echo 88 > /sys/class/gpio/export\n", "r"); - pclose(fp); - fp = popen("echo \"in\" > /sys/class/gpio/gpio88/direction\n", "r"); - pclose(fp); - fp = popen("chmod 0666 /sys/class/gpio/gpio88/value\n", "r"); - pclose(fp); - - fp = popen("echo 87 > /sys/class/gpio/export\n", "r"); - pclose(fp); - fp = popen("echo \"in\" > /sys/class/gpio/gpio87/direction\n", "r"); - pclose(fp); - fp = popen("chmod 0666 /sys/class/gpio/gpio87/value\n", "r"); - pclose(fp); - - if ( wiringPiISR (0, INT_EDGE_BOTH, &interruptB) < 0 ) { - printf ("Unable to setup ISR: %s\n", strerror (errno)); - return -1; - } - - if ( wiringPiISR (1, INT_EDGE_BOTH, &interruptA) < 0 ) { - printf ("Unable to setup ISR: %s\n", strerror (errno)); - return -1; - } -#endif + if(ENABLE_S6_BUTTON) { + setup_pin(S6_BUTTON, PUD_UP, &s6Alert); + } rotary_encoder_thread_id = g_thread_new( "rotary encoder", rotary_encoder_thread, NULL); if( ! rotary_encoder_thread_id ) @@ -1040,27 +792,24 @@ fprintf(stderr,"GPIO: ENABLE_CW_BUTTONS=%d CWL_BUTTON=%d CWR_BUTTON=%d\n",ENABL } fprintf(stderr, "rotary_encoder_thread: id=%p\n",rotary_encoder_thread_id); +#ifdef I2C + // setup i2c + i2c_init(); + + // setup interrupt pin + fprintf(stderr,"setup i2c interrupt: pin=%d\n",I2C_INTERRUPT); + digitalWrite(I2C_INTERRUPT,0); // clear pin + pinMode(I2C_INTERRUPT,INPUT); + pullUpDnControl(I2C_INTERRUPT,PUD_UP); + usleep(10000); + wiringPiISR(I2C_INTERRUPT,INT_EDGE_FALLING,pI2CInterrupt); +#endif return 0; } void gpio_close() { -fprintf(stderr,"gpio_close: lock\n"); - //g_mutex_lock(&m_running); running=0; -#ifdef GPIO -fprintf(stderr,"gpioTerminate\n"); - gpioTerminate(); -#endif -fprintf(stderr,"gpio_close: unlock\n"); - //g_mutex_unlock(&m_running); -#if defined odroid && !defined sx1509 - FILE *fp; - fp = popen("echo 87 > /sys/class/gpio/unexport\n", "r"); - pclose(fp); - fp = popen("echo 88 > /sys/class/gpio/unexport\n", "r"); - pclose(fp); -#endif } int vfo_encoder_get_pos() { @@ -1201,16 +950,6 @@ static encoder_changed(int action,int pos) { } set_drive(value); break; - case ENCODER_TUNE_DRIVE: - value=getTuneDrive(); - value+=(double)pos; - if(value<0.0) { - value=0.0; - } else if(value>100.0) { - value=100.0; - } - set_tune(value); - break; case ENCODER_RIT: value=(double)vfo[active_receiver->id].rit; value+=(double)(pos*rit_increment); @@ -1220,6 +959,9 @@ static encoder_changed(int action,int pos) { value=1000.0; } vfo[active_receiver->id].rit=(int)value; + if(protocol==NEW_PROTOCOL) { + schedule_high_priority(); + } vfo_update(NULL); break; case ENCODER_CW_SPEED: @@ -1341,16 +1083,10 @@ fprintf(stderr,"gpio_thread: unlock (running==0)\n"); //g_mutex_unlock(&m_running); g_thread_exit(NULL); } -#ifdef GPIO - usleep(100000); - //gpioDelay(100000); // 10 per second -#endif -#ifdef odroid usleep(100000); -#endif + //fprintf(stderr,"gpio_thread: unlock (running==1)\n"); //g_mutex_unlock(&m_running); } return NULL; } -#endif diff --git a/gpio.h b/gpio.h index fb60859..e6fd120 100644 --- a/gpio.h +++ b/gpio.h @@ -17,8 +17,8 @@ * */ -#ifndef _GPIO_H -#define _GPIO_H +#ifndef GPIO_H +#define GPIO_H enum { ENCODER_AF_GAIN=0,