Advertisement
Guest User

Untitled

a guest
Jan 28th, 2020
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.77 KB | None | 0 0
  1. /*
  2.  * GPIO.h
  3.  *
  4.  * Created: 1/28/2020 2:47:28 PM
  5.  *  Author: Ahmed
  6.  */
  7.  
  8.  
  9. #ifndef GPIO_H_
  10. #define GPIO_H_
  11.  
  12. #include <stdint.h>
  13.  
  14. #define  A 0
  15. #define B 1
  16. #define C 2
  17. #define D 3
  18.  
  19. #define INPUT 0
  20. #define  OUTPUT 1
  21.  
  22. #define HIGH 0xff
  23. #define LOW 0x00
  24.  
  25. #define PORTA 0x3b
  26. #define PORTB 0x38
  27. #define PORTC 0x35
  28. #define PORTD 0x32
  29.  
  30. #define PINS_NUMBER 8
  31. #define PORTS_NUMBER 4
  32.  
  33. #define  PULLUP_ON 1
  34. #define PULLUP_OFF 0;
  35.  
  36. static const uint8_t Ports_Addresses[PORTS_NUMBER] = {PORTA, PORTB, PORTC, PORTD};
  37.  
  38. #define BASE(id, offset) (Ports_Addresses[id] - offset)
  39.  
  40. void DIRECTION(uint8_t port, uint8_t pin, uint8_t dir, uint8_t pullup);
  41. char READ(uint8_t port, uint8_t pin);
  42. void WRITE(uint8_t port, uint8_t pin, uint8_t data);
  43.  
  44. #endif /* GPIO_H_ */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement