Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:software:homelab:library:pin [2010/12/30 13:28] allan.pettaien:software:homelab:library:pin [2020/07/20 12:00] (current) – external edit 127.0.0.1
Line 7: Line 7:
   * **//pin//** \\ Data type to hold pin registers addresses and bit mask. To get the most efficent program, //pin// typed variables should be constant, and they should be initialized at the beginning of the program code. Intializing can be done with the macro function //PIN//, whose first parameter is the port letter (capital A, B, C, etc) and the other one being the pin index (0 to 7). Only existing ports and pins can be used.   * **//pin//** \\ Data type to hold pin registers addresses and bit mask. To get the most efficent program, //pin// typed variables should be constant, and they should be initialized at the beginning of the program code. Intializing can be done with the macro function //PIN//, whose first parameter is the port letter (capital A, B, C, etc) and the other one being the pin index (0 to 7). Only existing ports and pins can be used.
  
-===== Functionalities =====+===== Constants ===== 
 +  * **//led_green, led_yellow, led_red//** - Homelab User interface board LEDs by colour 
 +  * **//LED1, LED2, LED3//** - Homelab User interface board LEDs by LED numbers 
 +  * **//S1, S2, S3//** - Homelab User interface board buttons 
 +   
 +===== Functions =====
  
   * **//void pin_setup_output(pin pin)//** \\   * **//void pin_setup_output(pin pin)//** \\
Line 68: Line 73:
  // Setting an output pin value  // Setting an output pin value
  pin_set_to(output_pin, !value);  pin_set_to(output_pin, !value);
 + }
 +}
 +</code>
 +
 +led_on, led_off, button_read commands example
 +<code c>
 +#include <homelab/pin.h>
 + 
 +// Homelab buttons and LEDs are predefined in the library
 +
 +int main(void)
 +{
 + // Set LED pin as output
 + pin_setup_output(led_green);
 +
 + // Set Button S1 pin as input
 + pin_setup_input(S1);
 +
 + // Endless loop
 + while (true)
 + {
 + // If button is pressed, turn on LED, if not pressed, turn LED off.
 + if(button_read(S1) == true)
 + led_on(led_green);
 + else
 + led_off(led_green);
  }  }
 } }
 </code> </code>
en/software/homelab/library/pin.1293708533.txt.gz · Last modified: (external edit)
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0