Open Garden  0.10.1-21
Functions
io_pin.c File Reference

IO lines low level API. More...

#include <stdlib.h>
#include <avr/io.h>
#include <util/delay.h>
#include "io_pin.h"
Include dependency graph for io_pin.c:

Functions

void onoff_pulse (const uint8_t status)
 
void valve_open (const uint8_t valvetype)
 
void valve_close (const uint8_t valvetype)
 
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...
 

Detailed Description

IO lines low level API.

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

◆ onoff_pulse()

void onoff_pulse ( const uint8_t  status)

send an On, Off or a pulse of PULSE_MSEC msec. on the OUT_CMD_ONOFF pin.

◆ valve_close()

void valve_close ( const uint8_t  valvetype)

Inverse of the valve_open().

Parameters
valvetypeMONOSTABLE or BISTABLE.

◆ valve_open()

void valve_open ( const uint8_t  valvetype)

Send the command to open the pre-selected valve.

Parameters
valvetypeMONOSTABLE or BISTABLE.
Note
Open a valve meaning water flows.