HWA
Bare metal programming with style
twia_1.h
Go to the documentation of this file.
1 
2 /* This file is part of the HWA project.
3  * Copyright (c) 2012,2015 Christophe Duparquet.
4  * All rights reserved. Read LICENSE.TXT for details.
5  */
6 
20 #define hw_class__twia
21 
22 /* Class logical registers
23  */
24 #define hw__twia_if _cb1, cr, 1, 7 // IRQ flasg
25 #define hw__twia_ack _cb1, cr, 1, 6 // Enable ACK
26 #define hw__twia_start _cb1, cr, 1, 5 // Tx START condition
27 #define hw__twia_stop _cb1, cr, 1, 4 // Tx STOP condition
28 #define hw__twia_collision _cb1, cr, 1, 3 // Collision flag
29 #define hw__twia_en _cb1, cr, 1, 2 // Enable TWI (take I/Os)
30 #define hw__twia_ie _cb1, cr, 1, 0 // Enable IRQs
31 
32 #define hw__twia_status _cb1, sr, 5, 3 // Status code
33 #define hw__twia_psc _cb1, sr, 2, 0 // Prescaler
34 
35 #define hw__twia_sla _cb1, ar, 7, 1 // Slave address
36 #define hw__twia_gce _cb1, ar, 1, 0 // General Call Enable
37 
38 #define hw__twia_slam _cb1, amr, 7, 1 // Slave address mask
39 
40 /* Values for CR
41  */
42 #define _hw_twia_cr_ifenstart 0xA4
43 #define _hw_twia_cr_ifenstartie 0xA5
44 #define _hw_twia_cr_ifen 0x84
45 #define _hw_twia_cr_ifenie 0x85
46 #define _hw_twia_cr_ifenstop 0x94
47 #define _hw_twia_cr_ifenstopie 0x95
48 #define _hw_twia_cr_ifenack 0xC4
49 #define _hw_twia_cr_ifenackie 0xC5
50 
51 
61 #if !defined __ASSEMBLER__
62 
63 /* HWA context
64  */
65 typedef struct {
66 
67  /* Hardware registers
68  */
69  hwa_r8_t br ;
70  hwa_r8_t cr ;
71  hwa_r8_t sr ;
72  hwa_r8_t ar ;
73  hwa_r8_t amr ;
74 } hwa_twia_t ;
75 
76 #endif