diff --git a/pigpio.c b/pigpio.c index 2ca1962..4588b38 100644 --- a/pigpio.c +++ b/pigpio.c @@ -25,7 +25,7 @@ OTHER DEALINGS IN THE SOFTWARE. For more information, please refer to */ -/* pigpio version 53 */ +/* pigpio version 54 */ /* include ------------------------------------------------------- */ @@ -4238,27 +4238,27 @@ static void spiInit(uint32_t flags) if (!(resvd&1)) { - gpioSetMode(PI_ASPI_CE0, PI_OUTPUT); + myGpioSetMode(PI_ASPI_CE0, PI_OUTPUT); myGpioWrite(PI_ASPI_CE0, !(cspols&1)); } if (!(resvd&2)) { - gpioSetMode(PI_ASPI_CE1, PI_OUTPUT); + myGpioSetMode(PI_ASPI_CE1, PI_OUTPUT); myGpioWrite(PI_ASPI_CE1, !(cspols&2)); } if (!(resvd&4)) { - gpioSetMode(PI_ASPI_CE2, PI_OUTPUT); + myGpioSetMode(PI_ASPI_CE2, PI_OUTPUT); myGpioWrite(PI_ASPI_CE2, !(cspols&4)); } /* set gpios to SPI mode */ - gpioSetMode(PI_ASPI_SCLK, PI_ALT4); - gpioSetMode(PI_ASPI_MISO, PI_ALT4); - gpioSetMode(PI_ASPI_MOSI, PI_ALT4); + myGpioSetMode(PI_ASPI_SCLK, PI_ALT4); + myGpioSetMode(PI_ASPI_MISO, PI_ALT4); + myGpioSetMode(PI_ASPI_MOSI, PI_ALT4); } else { @@ -4275,12 +4275,12 @@ static void spiInit(uint32_t flags) /* set gpios to SPI mode */ - if (!(resvd&1)) gpioSetMode(PI_SPI_CE0, PI_ALT0); - if (!(resvd&2)) gpioSetMode(PI_SPI_CE1, PI_ALT0); + if (!(resvd&1)) myGpioSetMode(PI_SPI_CE0, PI_ALT0); + if (!(resvd&2)) myGpioSetMode(PI_SPI_CE1, PI_ALT0); - gpioSetMode(PI_SPI_SCLK, PI_ALT0); - gpioSetMode(PI_SPI_MISO, PI_ALT0); - gpioSetMode(PI_SPI_MOSI, PI_ALT0); + myGpioSetMode(PI_SPI_SCLK, PI_ALT0); + myGpioSetMode(PI_SPI_MISO, PI_ALT0); + myGpioSetMode(PI_SPI_MOSI, PI_ALT0); } } @@ -4298,13 +4298,13 @@ static void spiTerm(uint32_t flags) /* restore original state */ - if (!(resvd&1)) gpioSetMode(PI_ASPI_CE0, old_mode_ace0); - if (!(resvd&2)) gpioSetMode(PI_ASPI_CE1, old_mode_ace1); - if (!(resvd&4)) gpioSetMode(PI_ASPI_CE2, old_mode_ace2); + if (!(resvd&1)) myGpioSetMode(PI_ASPI_CE0, old_mode_ace0); + if (!(resvd&2)) myGpioSetMode(PI_ASPI_CE1, old_mode_ace1); + if (!(resvd&4)) myGpioSetMode(PI_ASPI_CE2, old_mode_ace2); - gpioSetMode(PI_ASPI_SCLK, old_mode_asclk); - gpioSetMode(PI_ASPI_MISO, old_mode_amiso); - gpioSetMode(PI_ASPI_MOSI, old_mode_amosi); + myGpioSetMode(PI_ASPI_SCLK, old_mode_asclk); + myGpioSetMode(PI_ASPI_MISO, old_mode_amiso); + myGpioSetMode(PI_ASPI_MOSI, old_mode_amosi); auxReg[AUX_SPI0_CNTL0_REG] = old_spi_cntl0; auxReg[AUX_SPI0_CNTL1_REG] = old_spi_cntl1; @@ -4313,12 +4313,12 @@ static void spiTerm(uint32_t flags) { /* restore original state */ - if (!(resvd&1)) gpioSetMode(PI_SPI_CE0, old_mode_ce0); - if (!(resvd&2)) gpioSetMode(PI_SPI_CE1, old_mode_ce1); + if (!(resvd&1)) myGpioSetMode(PI_SPI_CE0, old_mode_ce0); + if (!(resvd&2)) myGpioSetMode(PI_SPI_CE1, old_mode_ce1); - gpioSetMode(PI_SPI_SCLK, old_mode_sclk); - gpioSetMode(PI_SPI_MISO, old_mode_miso); - gpioSetMode(PI_SPI_MOSI, old_mode_mosi); + myGpioSetMode(PI_SPI_SCLK, old_mode_sclk); + myGpioSetMode(PI_SPI_MISO, old_mode_miso); + myGpioSetMode(PI_SPI_MOSI, old_mode_mosi); spiReg[SPI_CS] = old_spi_cs; spiReg[SPI_CLK] = old_spi_clk; @@ -8049,10 +8049,10 @@ int gpioSetMode(unsigned gpio, unsigned mode) switchFunctionOff(gpio); gpioInfo[gpio].is = GPIO_UNDEFINED; - - gpioReg[reg] = (gpioReg[reg] & ~(7< #include #include -#define PIGPIO_VERSION 53 +#define PIGPIO_VERSION 54 /*TEXT diff --git a/pigs.1 b/pigs.1 index 31aec3c..e55c554 100644 --- a/pigs.1 +++ b/pigs.1 @@ -1808,16 +1808,17 @@ Upon success the new frequency is returned. On error a negative status code will be returned. .br -The selectable frequencies depend upon the sample rate with which the -pigpiod daemon was started. The sample rate is one of 1, 2, 4, 5, 8, -or 10 microseconds (default 5). +If PWM is currently active on the GPIO it will be +switched off and then back on at the new frequency. .br -Each GPIO can be independently set to one of 18 different PWM frequencies. +Each GPIO can be independently set to one of 18 different PWM +frequencies. .br -If PWM is currently active on the GPIO it will be switched off and then -back on at the new frequency. +The selectable frequencies depend upon the sample rate which +may be 1, 2, 4, 5, 8, or 10 microseconds (default 5). The +sample rate is set when the pigpio daemon is started. .br The frequencies for each sample rate are: @@ -1825,21 +1826,46 @@ The frequencies for each sample rate are: .br .EX - #1 #2 #3 #4 #5 #6 #7 #8 #9 - 1us 40000 20000 10000 8000 5000 4000 2500 2000 1600 - 2us 20000 10000 5000 4000 2500 2000 1250 1000 800 - 4us 10000 5000 2500 2000 1250 1000 625 500 400 - 5us 8000 4000 2000 1600 1000 800 500 400 320 - 8us 5000 2500 1250 1000 625 500 313 250 200 -10us 4000 2000 1000 800 500 400 250 200 160 - - #10 #11 #12 #13 #14 #15 #16 #17 #18 - 1us 1250 1000 800 500 400 250 200 100 50 - 2us 625 500 400 250 200 125 100 50 25 - 4us 313 250 200 125 100 63 50 25 13 - 5us 250 200 160 100 80 50 40 20 10 - 8us 156 125 100 63 50 31 25 13 6 -10us 125 100 80 50 40 25 20 10 5 + Hertz +.br + +.br + 1: 40000 20000 10000 8000 5000 4000 2500 2000 1600 +.br + 1250 1000 800 500 400 250 200 100 50 +.br + +.br + 2: 20000 10000 5000 4000 2500 2000 1250 1000 800 +.br + 625 500 400 250 200 125 100 50 25 +.br + +.br + 4: 10000 5000 2500 2000 1250 1000 625 500 400 +.br + 313 250 200 125 100 63 50 25 13 +.br +sample +.br + rate +.br + (us) 5: 8000 4000 2000 1600 1000 800 500 400 320 +.br + 250 200 160 100 80 50 40 20 10 +.br + +.br + 8: 5000 2500 1250 1000 625 500 313 250 200 +.br + 156 125 100 63 50 31 25 13 6 +.br + +.br + 10: 4000 2000 1000 800 500 400 250 200 160 +.br + 125 100 80 50 40 25 20 10 5 +.br .EE @@ -3393,7 +3419,7 @@ pigs wvcha \ .br .br -while \fB $(pigs wvbsy) -eq 1 \fP; do sleep 0.1; done +while [[ $(pigs wvbsy) -eq 1 ]]; do sleep 0.1; done .br .br @@ -4314,7 +4340,7 @@ Again, ignore the details for now. .br .EX -time (pigs procr 0 10000000; while a=$(pigs procp 0); \fB ${a::1} -eq 2 \fP;\ +time (pigs procr 0 10000000; while a=$(pigs procp 0); [[ ${a::1} -eq 2 ]];\ .br do sleep 0.2; done) .br @@ -4354,7 +4380,7 @@ jp 999 jumps to tag 999 if the result is positive. .br .EX -time (pigs procr 0 10000000; while a=$(pigs procp 0); \fB ${a::1} -eq 2 \fP;\ +time (pigs procr 0 10000000; while a=$(pigs procp 0); [[ ${a::1} -eq 2 ]];\ .br do sleep 0.2; done) .br