MCPcopy Create free account
hub / github.com/WiringPi/WiringPi / pinModeAlt

Function pinModeAlt

wiringPi/wiringPi.c:1871–1926  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1869 */
1870
1871void pinModeAlt (int pin, int mode)
1872{
1873 setupCheck ("pinModeAlt") ;
1874
1875 if (!ToBCMPin(&pin)) {
1876 return;
1877 }
1878
1879 if (piRP1Model()) {
1880 //confusion! diffrent to to BCM! this is taking directly the value for the register
1881 int modeRP1;
1882 switch(mode) {
1883 case FSEL_ALT0:
1884 modeRP1 = 0;
1885 break;
1886 case FSEL_ALT1:
1887 modeRP1 = 1;
1888 break;
1889 case FSEL_ALT2:
1890 modeRP1 = 2;
1891 break;
1892 case FSEL_ALT3:
1893 modeRP1 = 3;
1894 break;
1895 case FSEL_ALT4:
1896 modeRP1 = 4;
1897 break;
1898 case FSEL_ALT5:
1899 modeRP1 = 5;
1900 break;
1901 case FSEL_ALT6:
1902 modeRP1 = 6;
1903 break;
1904 case FSEL_ALT7:
1905 modeRP1 = 7;
1906 break;
1907 case FSEL_ALT8:
1908 modeRP1 = 8;
1909 break;
1910 case FSEL_OUTP:
1911 case FSEL_INPT:
1912 modeRP1 = RP1_FSEL_GPIO;
1913 break;
1914 default:
1915 fprintf(stderr, "pinModeAlt: invalid mode %d\n", mode);
1916 return;
1917 }
1918 //printf("pinModeAlt: Pi5 alt pin %d to %d\n", pin, modeRP1);
1919 gpio[2*pin+1] = (modeRP1 & RP1_FSEL_NONE_HW) | RP1_DEBOUNCE_DEFAULT; //0-4 function, 5-11 debounce time
1920 } else {
1921 int fSel = gpioToGPFSEL [pin] ;
1922 int shift = gpioToShift [pin] ;
1923
1924 *(gpio + fSel) = (*(gpio + fSel) & ~(7 << shift)) | ((mode & 0x7) << shift) ;
1925 }
1926 }
1927
1928

Callers 2

doModeFunction · 0.85
pinModeFunction · 0.85

Calls 3

setupCheckFunction · 0.85
ToBCMPinFunction · 0.85
piRP1ModelFunction · 0.85

Tested by

no test coverage detected