Zookeeper
1. Void pinmode (INT pin, int mode );
This function sets the Input and Output Modes of the pin and the input and output modes of PWM. InWiringpi onlyPin 1 (bcm_gpio 18) supports PWM output.
2. Void digitalwrite (INT pin, int value );
This function is used to set the level of the pin. When we write high or low (1 or 0), the mode of the pin must be the output mode.
3. Void digitalwritebyte (INT value );
This function can write 8-bit bytes to 8 gpio pin pins, which is the fastest way to set 8 pin values.
4. Void pwmwrite (INT pin, int value );
This function writes a value to the PWM register and controls the gpio value. The written value must be 0-1024.
5. Int digitalread (INT pin );
This function reads the level of the gpio pin and returns the read value.
6. Void pullupdncontrol (INT pin, int PUD );
This function is used to set whether the pin of gpio is connected to the pulling and pulling resistors. The pud parameter of the function must be set. If it is set to pud_off, it indicates that there is no pull-up or drop-down resistor. If it is set to pud_down, it indicates the drop-down resistor. If it is set to pud_up, it indicates the pull-up resistor.
PWM control:
1. pwmsetmode (INT mode );
This function is used to set the PWM duty cycle mode, which is generally 50% duty cycle and adjustable duty cycle mode. Raspberry Pi uses the 50% duty cycle mode by default. We can set the two parameters pwm_mode_bal and pwm_mode_ms.
2. pwmsetrange (unsigned int range );
This function is used to set the write range of the PWM register. The default value is 1024.
3. pwmsetclock (INT divisor );
This function sets the frequency division factor of the PWM clock.
Scheduled function:
1. Void delay (unsigned int Howlong)
This is a latency function in milliseconds.
2. Void delaymicroseconds (unsigned int Howlong)
Latency functions in microseconds
Interrupt functions:
1. Int waitforinterrupt (INT pin, int timeout );
This wait event interrupt function, the timeout parameter is a millisecond-level parameter. When it is-1, the table will always wait for the interrupt state. If the returned value is-1, 0, it indicates timeout, and 1 indicates successful interruption. Before calling this function, we need to initialize gpio.
For example, we want to set gpio 0 to wait for the disconnection of the descent edge:
We need to run gpio edge 0 falling on the terminal before running the program.
2. Int wiringpiisr (INT pin, int edgetype, void (* function) (void ));
This function uses a function as a parameter to obtain the interrupt at a specific gpio pin. The edge_type parameter can be set to int_edge_falling, int_edge_rising, int_edge_both or int_edge_setup.
When an interruption occurs, the function will be called. before calling the function, the corresponding flag is cleared, so that subsequent interruptions will not be affected.
These functions will be helpful for applications that write gpio operations.
Introduction to common functions of Raspberry Pi wiringpi