Open Garden  0.10.1-21
Data Structures | Macros | Functions | Variables
io_pin.h File Reference

IO lines definitions. More...

#include "ogstruct.h"
Include dependency graph for io_pin.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  iolines_t
 

Macros

#define OUT_PORT   PORTA
 
#define OUT_PIN   PINA
 
#define OUT_DDR   DDRA
 
#define OUT_P0   PA0
 
#define OUT_P1   PA1
 
#define OUT_P2   PA2
 
#define OUT_P3   PA3
 
#define OUT_P4   PA4
 
#define OUT_P5   PA5
 
#define OUT_P6   PA6
 
#define OUT_P7   PA7
 
#define IN_PORT   PORTD
 
#define IN_PIN   PIND
 
#define IN_DDR   DDRD
 
#define IN_P0   PIND4
 
#define IN_P1   PIND5
 
#define OUT_CMD_PORT   PORTB
 
#define OUT_CMD_DDR   DDRB
 
#define OUT_CMD_ONOFF   PB0
 
#define OUT_CMD_PN   PB1
 
#define OFF   0
 
#define ON   1
 
#define PULSE   2
 
#define PULSE_MSEC   50
 

Functions

void io_suspend (void)
 
void io_resume (void)
 
void io_init (void)
 
void io_shut (void)
 Shutdown all I/O pin. More...
 
void io_set (const uint8_t oline, const uint8_t onoff, struct programs_t *progs)
 
uint8_t io_get (struct programs_t *progs)
 
void io_off (struct programs_t *progs)
 
uint8_t io_alarm (struct programs_t *progs)
 get alarm status. More...
 

Variables

struct iolines_tiolines
 

Detailed Description

IO lines definitions.

Macro Definition Documentation

◆ IN_DDR

#define IN_DDR   DDRD

Alarm DDR

◆ IN_P0

#define IN_P0   PIND4

Alarm line 0

◆ IN_P1

#define IN_P1   PIND5

Alarm line 1

◆ IN_PIN

#define IN_PIN   PIND

Alarm PIN

◆ IN_PORT

#define IN_PORT   PORTD

Alarm port

◆ OFF

#define OFF   0

Macro OFF

◆ ON

#define ON   1

Macro ON

◆ OUT_CMD_DDR

#define OUT_CMD_DDR   DDRB

Command DDR

◆ OUT_CMD_ONOFF

#define OUT_CMD_ONOFF   PB0

Command On Off line 0

◆ OUT_CMD_PN

#define OUT_CMD_PN   PB1

Command +- line

◆ OUT_CMD_PORT

#define OUT_CMD_PORT   PORTB

Command PORT

◆ OUT_DDR

#define OUT_DDR   DDRA

IO DDR

◆ OUT_P0

#define OUT_P0   PA0

IO line 0

◆ OUT_P1

#define OUT_P1   PA1

IO line 1

◆ OUT_P2

#define OUT_P2   PA2

IO line 2

◆ OUT_P3

#define OUT_P3   PA3

IO line 3

◆ OUT_P4

#define OUT_P4   PA4

IO line 4

◆ OUT_P5

#define OUT_P5   PA5

IO line 5

◆ OUT_P6

#define OUT_P6   PA6

IO line 6

◆ OUT_P7

#define OUT_P7   PA7

IO line 7

◆ OUT_PIN

#define OUT_PIN   PINA

IO PIN

◆ OUT_PORT

#define OUT_PORT   PORTA

the IO line port

◆ PULSE

#define PULSE   2

Macro PULSE

◆ PULSE_MSEC

#define PULSE_MSEC   50

PULSE msec delay

Function Documentation

◆ io_alarm()

uint8_t io_alarm ( struct programs_t progs)

get alarm status.

Sets/clear and return the alarm flag in the flag register (FL_ALRM) if one or both the alarm line are set, based on the alarm level trigger (FL_LEVEL high or low).

Parameters
progsthe struct to look for the alarm level setup.
Returns
0 - 3 the alarm line active in binary mapping.

◆ io_get()

uint8_t io_get ( struct programs_t progs)

Are there any IO out line in use?

◆ io_init()

void io_init ( void  )

setup the I/O port.

◆ io_off()

void io_off ( struct programs_t progs)

Close all the output line.

Note
the oline is ignored since there must be only one oline in use.

◆ io_set()

void io_set ( const uint8_t  oline,
const uint8_t  onoff,
struct programs_t progs 
)

Set I/O oline.

open or close the I/O line, the OUT_PORT is supposed to represent the correct status of the I/O lines only if the valve type is MONOSTABLE. In the open case, we set the port to the corresponding oline, then we also set the oline into the progs structure in order to remember which ioline we are using, because this info will be lost during the stand-by period. Then, after opened the valve, if the valve is BISTABLE we can clear the oline from the port, no need to keep the line up; instead if the valve is MONOSTABLE then the PORT represent the ioline in use and it must not be cleared. In the close case and bistable valve, the port must be set to the correct ioline before the close operation or it will not affect any line.

Special case: GTP hardware. Monostable valve ignore the ON/OFF line. Bistable valve uses +/- and ON/OFF line in a different way, to open: set the ioline and the ON/OFF to 1, after 1msec clear the ioline and after PULSE_MSEC clear also the ON/OFF line. to close: set the ioline and the +/- to 1, after 1msec clear the ioline and after PULSE_MSEC clear also the +/- line.

Parameters
olinethe output line to be set.
onoffset or clear.
progsptr to the parameters.
Note
online is in the range 0 to 7.
no more than 1 line can be used at the same time.
if OFF, the oline param is ignored, there should be only 1 oline in use to be closed.

◆ io_shut()

void io_shut ( void  )

Shutdown all I/O pin.

Not only make them 0, but also release the IO lines.

◆ io_suspend()

void io_suspend ( void  )

release all the I/O lines before suspend