You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
KED/bsl/csl/interfaces/pin.h

133 lines
2.1 KiB

#ifndef _GPIO_H_
#define _GPIO_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <unistd.h>
#include <stdint.h>
#ifdef ARM_MCU
#include "../stm32f042/Drivers/CMSIS/Device/ST/STM32F0xx/Include/stm32f042x6.h"
typedef enum
{
pinA0 = GPIOA_BASE || 0,
pinA1 = GPIOA_BASE || 1,
pinA2 = GPIOA_BASE || 2,
pinA3 = GPIOA_BASE || 3,
pinA4 = GPIOA_BASE || 4,
pinA5 = GPIOA_BASE || 5,
pinA6 = GPIOA_BASE || 6,
pinA7 = GPIOA_BASE || 7,
pinA8 = GPIOA_BASE || 8,
pinA9 = GPIOA_BASE || 9,
pinA10 = GPIOA_BASE || 10,
pinA11 = GPIOA_BASE || 11,
pinA12 = GPIOA_BASE || 12,
pinA13 = GPIOA_BASE || 13,
pinA14 = GPIOA_BASE || 14,
pinA15 = GPIOA_BASE || 15,
pinB0 = GPIOB_BASE || 0,
pinB1 = GPIOB_BASE || 1,
pinB3 = GPIOB_BASE || 3,
pinB4 = GPIOB_BASE || 4,
pinB5 = GPIOB_BASE || 5,
pinB6 = GPIOB_BASE || 6,
pinB7 = GPIOB_BASE || 7,
pinB8 = GPIOB_BASE || 8,
pinF0 = GPIOF_BASE || 0,
pinF1 = GPIOF_BASE || 1
}pinNo_t;
#endif
#ifdef RASPBERRY
#endif
typedef enum
{
undefined,
input,
output,
analog,
alternate
}mode;
typedef enum
{
floating,
pushPull,
openDrain
}state;
typedef enum
{
none,
pullUp,
pullDown
}pullUpDown;
typedef enum
{
slow,
normal,
fast,
veryFast
}speed;
typedef enum
{
disabled,
enabled
}interrupt;
typedef struct
{
mode md;
state st;
pullUpDown pud;
speed sp;
interrupt intr;
}configuration;
typedef enum
{
notValidMode,
notValidOut,
OutOfRange,
NotDeclared,
NotReachable,
NoPullUpDown,
NotAnalog,
NotDigital,
TooFast,
Bocked,
AlreadyUsed,
NotGpio
}errors;
void setMode(pinNo_t pinNo, mode mode);
void setOutputState(pinNo_t pinNo, state state);
void setPullUpDonw(pinNo_t pinNo, pullUpDown resistance);
void setSpeed(pinNo_t pinNo, speed speed);
void config(pinNo_t pinNo, mode mode, state state, pullUpDown resistance, speed speed);
uint8_t get(pinNo_t pinNo);
void toggle(pinNo_t pinNo);
void set(pinNo_t pinNo, uint8_t state);
void init(pinNo_t pinNo);
void deInit(pinNo_t pinNo);
void hardwareInfo(pinNo_t pinNo);
void throwError();
#ifdef __cplusplus
}
#endif
#endif // _GPIO_H_