Contiki 3.x
port2.h
1 /*
2 Copyright (c) 2012, Philippe Retornaz
3 Copyright (c) 2012, EPFL STI IMT LSRO1 -- Mobots group
4 All rights reserved.
5 
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions
8 are met:
9 1. Redistributions of source code must retain the above copyright
10  notice, this list of conditions and the following disclaimer.
11 2. Redistributions in binary form must reproduce the above copyright
12  notice, this list of conditions and the following disclaimer in the
13  documentation and/or other materials provided with the distribution.
14 3. The name of the author may not be used to endorse or promote
15  products derived from this software without specific prior
16  written permission.
17 
18 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
19 OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
22 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
24 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30 
31 #ifndef CC253x_P2_INTR_H_
32 #define CC253x_P2_INTR_H_
33 
34 #include "contiki.h"
35 
36 #define CC253x_P2_ACK 0x1
37 #define CC253x_P2_NACK 0x0
38 
39 struct cc253x_p2_handler {
40  struct cc253x_p2_handler *next;
41  uint8_t (* cb)(void);
42 };
43 
44 void cc253x_p2_register_handler(struct cc253x_p2_handler *h);
45 
46 void cc253x_p2_unregister_handler(struct cc253x_p2_handler *h);
47 
48 /* When the ISR is not needed, hide its prototype from the module containing
49  * main() to prevent linking it */
50 #if PORT_2_ISR_ENABLED
51 void port_2_isr(void) __interrupt(P2INT_VECTOR);
52 #endif
53 
54 #define cc253x_p2_irq_disable(flag) do { flag = IEN2 & 0x2; IEN2 &= ~0x2; } while(0)
55 #define cc253x_p2_irq_enable(flag) do { IEN2 |= flag; } while(0)
56 
57 #define cc253x_p2_irq_force_enable() cc253x_p2_irq_enable(0x2)
58 
59 #endif