| 1403 | */ |
| 1404 | |
| 1405 | int getAlt (int pin) |
| 1406 | { |
| 1407 | int alt; |
| 1408 | |
| 1409 | if (!ToBCMPin(&pin)) { |
| 1410 | return 0; |
| 1411 | } |
| 1412 | |
| 1413 | if (piRP1Model()) { |
| 1414 | alt = (gpio[2*pin+1] & RP1_FSEL_NONE_HW); //0-4 function |
| 1415 | |
| 1416 | /* |
| 1417 | BCM: |
| 1418 | 000b = GPIO Pin 9 is an input |
| 1419 | 001b = GPIO Pin 9 is an output |
| 1420 | 100b = GPIO Pin 9 takes alternate function 0 |
| 1421 | 101b = GPIO Pin 9 takes alternate function 1 |
| 1422 | 110b = GPIO Pin 9 takes alternate function 2 |
| 1423 | 111b = GPIO Pin 9 takes alternate function 3 |
| 1424 | 011b = GPIO Pin 9 takes alternate function 4 |
| 1425 | 010b = GPIO Pin 9 takes alternate function 5 |
| 1426 | RP1: |
| 1427 | 8 = alternate function 6 |
| 1428 | 9 = alternate function 7 |
| 1429 | 10 = alternate function 8 |
| 1430 | 11 = alternate function 9 |
| 1431 | */ |
| 1432 | switch(alt) { |
| 1433 | case 0: return FSEL_ALT0; |
| 1434 | case 1: return FSEL_ALT1; |
| 1435 | case 2: return FSEL_ALT2; |
| 1436 | case 3: return FSEL_ALT3; |
| 1437 | case 4: return FSEL_ALT4; |
| 1438 | case RP1_FSEL_GPIO: { |
| 1439 | unsigned int outputmask = gpio[2*pin] & 0x3000; //Bit13-OETOPAD + Bit12-OEFROMPERI |
| 1440 | return (outputmask==0x3000) ? FSEL_OUTP : FSEL_INPT; |
| 1441 | } |
| 1442 | case 6: return FSEL_ALT6; |
| 1443 | case 7: return FSEL_ALT7; |
| 1444 | case 8: return FSEL_ALT8; |
| 1445 | case RP1_FSEL_NONE: return FSEL_ALT9; |
| 1446 | default:return alt; |
| 1447 | } |
| 1448 | } else { |
| 1449 | int fSel = gpioToGPFSEL [pin] ; |
| 1450 | int shift = gpioToShift [pin] ; |
| 1451 | |
| 1452 | alt = (*(gpio + fSel) >> shift) & 7 ; |
| 1453 | } |
| 1454 | return alt; |
| 1455 | } |
| 1456 | |
| 1457 | |
| 1458 | enum WPIPinAlt getPinModeAlt(int pin) { |
no test coverage detected