Change definition of NO_PIN to 1+PIN_MAX (#1231)

Fixes bug #1228 that gpio 0 could not be used by the linuxgpio system.

* Add sanity checks
* Loop over defined pins only

Co-authored-by: Stefan Rueger <stefan.rueger@urclocks.com>
This commit is contained in:
Bas Wijnen
2023-01-02 15:23:01 +01:00
committed by GitHub
parent b6d50ef0a9
commit dc0ab33a58
13 changed files with 125 additions and 87 deletions

View File

@@ -608,8 +608,13 @@ int bitbang_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
return 0;
}
static int verify_pin_assigned(const PROGRAMMER *pgm, int pin, char *desc) {
if (pgm->pinno[pin] == 0) {
static int verify_pin_assigned(const PROGRAMMER *pgm, int pinfunc, char *desc) {
if(pinfunc < 0 || pinfunc >= N_PINS) {
pmsg_error("invalid pin function number %d\n", pinfunc);
return -1;
}
if ((pgm->pinno[pinfunc] & PIN_MASK) > PIN_MAX) {
pmsg_error("no pin has been assigned for %s\n", desc);
return -1;
}