Added some test code for the relays
[cerebrum.git] / msp / simple-io.c.tp
blob904dcf602e8b100d23a469fab148f02310b5a879
1 /*
2  Copyright (C) 2012 jaseg <s@jaseg.de>
4  This program is free software; you can redistribute it and/or
5  modify it under the terms of the GNU General Public License
6  version 3 as published by the Free Software Foundation.
7  */
9 #include <msp430.h>
11 void ${init_function()} (void){
14 //${modulevar("state", None, "B")}
15 void callback_set_${modulevar("state")} (uint16_t payload_offset, uint16_t argsize, uint8_t* args){
16         P${member["port"]}OUT &= ~(1<<${member["pin"]});
17         if(args[0])
18                 P${member["port"]}OUT |= (1<<${member["pin"]});
19         uart_putc(0x00);
20         uart_putc(0x00);
21         uart_putc(0x00);
22         uart_putc(0x00);
25 void callback_get_${modulevar("state")} (uint16_t payload_offset, uint16_t argsize, uint8_t* args){
26         uart_putc(0x00);
27         uart_putc(0x01);
28         uart_putc(!!(P${member["port"]}IN & (1<<${member["pin"]})));
29         uart_putc(0x00);
30         uart_putc(0x00);
33 //${modulevar("direction", None, "B")}
34 void callback_set_${modulevar("direction")} (uint16_t payload_offset, uint16_t argsize, uint8_t* args){
35         P${member["port"]}DIR &= ~(1<<${member["pin"]});
36         if(args[0])
37                 P${member["port"]}DIR |= (1<<${member["pin"]});
38         uart_putc(0x00);
39         uart_putc(0x00);
40         uart_putc(0x00);
41         uart_putc(0x00);
44 void callback_get_${modulevar("direction")} (uint16_t payload_offset, uint16_t argsize, uint8_t* args){
45         uart_putc(0x00);
46         uart_putc(0x01);
47         uart_putc(!!(P${member["port"]}DIR & (1<<${member["pin"]})));
48         uart_putc(0x00);
49         uart_putc(0x00);