FreeCalypso > hg > freecalypso-sw
annotate gsm-fw/bsp/abb+spi/abb_inline.h @ 718:537f0f059574
mm_em.c compiles
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Sat, 04 Oct 2014 00:54:26 +0000 |
parents | cc0944d35698 |
children |
rev | line source |
---|---|
587
cc0944d35698
gsm-fw/bsp/abb+spi/*.h: formatting fixes (line length and tabs)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
1 /******************************************************************************/ |
cc0944d35698
gsm-fw/bsp/abb+spi/*.h: formatting fixes (line length and tabs)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
2 /* TEXAS INSTRUMENTS INCORPORATED PROPRIETARY INFORMATION */ |
cc0944d35698
gsm-fw/bsp/abb+spi/*.h: formatting fixes (line length and tabs)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
3 /* */ |
cc0944d35698
gsm-fw/bsp/abb+spi/*.h: formatting fixes (line length and tabs)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
4 /* Property of Texas Instruments -- For Unrestricted Internal Use Only */ |
cc0944d35698
gsm-fw/bsp/abb+spi/*.h: formatting fixes (line length and tabs)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
5 /* Unauthorized reproduction and/or distribution is strictly prohibited. This*/ |
cc0944d35698
gsm-fw/bsp/abb+spi/*.h: formatting fixes (line length and tabs)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
6 /* product is protected under copyright law and trade secret law as an*/ |
cc0944d35698
gsm-fw/bsp/abb+spi/*.h: formatting fixes (line length and tabs)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
7 /* unpublished work. Created 1987, (C) Copyright 1997 Texas Instruments. All*/ |
cc0944d35698
gsm-fw/bsp/abb+spi/*.h: formatting fixes (line length and tabs)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
8 /* rights reserved. */ |
cc0944d35698
gsm-fw/bsp/abb+spi/*.h: formatting fixes (line length and tabs)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
9 /* */ |
cc0944d35698
gsm-fw/bsp/abb+spi/*.h: formatting fixes (line length and tabs)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
10 /* */ |
cc0944d35698
gsm-fw/bsp/abb+spi/*.h: formatting fixes (line length and tabs)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
11 /* Filename : abb_inline.h */ |
cc0944d35698
gsm-fw/bsp/abb+spi/*.h: formatting fixes (line length and tabs)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
12 /* */ |
cc0944d35698
gsm-fw/bsp/abb+spi/*.h: formatting fixes (line length and tabs)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
13 /* Description : inline functions to drive the ABB device. */ |
cc0944d35698
gsm-fw/bsp/abb+spi/*.h: formatting fixes (line length and tabs)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
14 /* The Serial Port Interface is used to connect the TI */ |
cc0944d35698
gsm-fw/bsp/abb+spi/*.h: formatting fixes (line length and tabs)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
15 /* Analog BaseBand (ABB). */ |
cc0944d35698
gsm-fw/bsp/abb+spi/*.h: formatting fixes (line length and tabs)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
16 /* It is assumed that the ABB is connected as the SPI */ |
cc0944d35698
gsm-fw/bsp/abb+spi/*.h: formatting fixes (line length and tabs)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
17 /* device 0. */ |
cc0944d35698
gsm-fw/bsp/abb+spi/*.h: formatting fixes (line length and tabs)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
18 /* */ |
cc0944d35698
gsm-fw/bsp/abb+spi/*.h: formatting fixes (line length and tabs)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
19 /* Author : Pascal PUEL */ |
cc0944d35698
gsm-fw/bsp/abb+spi/*.h: formatting fixes (line length and tabs)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
20 /* */ |
cc0944d35698
gsm-fw/bsp/abb+spi/*.h: formatting fixes (line length and tabs)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
21 /* Version number : 1.0 */ |
cc0944d35698
gsm-fw/bsp/abb+spi/*.h: formatting fixes (line length and tabs)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
22 /* */ |
cc0944d35698
gsm-fw/bsp/abb+spi/*.h: formatting fixes (line length and tabs)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
23 /* Date and time : Dec 2002 */ |
cc0944d35698
gsm-fw/bsp/abb+spi/*.h: formatting fixes (line length and tabs)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
24 /* */ |
cc0944d35698
gsm-fw/bsp/abb+spi/*.h: formatting fixes (line length and tabs)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
25 /* Previous delta : Creation */ |
cc0944d35698
gsm-fw/bsp/abb+spi/*.h: formatting fixes (line length and tabs)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
26 /* */ |
cc0944d35698
gsm-fw/bsp/abb+spi/*.h: formatting fixes (line length and tabs)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
27 /******************************************************************************/ |
148
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
28 |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
29 #ifndef __ABB_INLINE_H__ |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
30 #define __ABB_INLINE_H__ |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
31 |
149
971e84124a6f
gsm-fw/bsp/abb+spi: preening of header files, first pass
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
32 #include "../../include/config.h" |
971e84124a6f
gsm-fw/bsp/abb+spi: preening of header files, first pass
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
33 #include "../../include/sys_types.h" |
148
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
34 |
149
971e84124a6f
gsm-fw/bsp/abb+spi: preening of header files, first pass
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
35 #include "spi_drv.h" |
148
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
36 |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
37 // MACROS |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
38 #define ABB_WRITE_REG(reg, data) { \ |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
39 SPI_WRITE_TX_MSB((data << 6) | reg) \ |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
40 SPI_START_WRITE } |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
41 |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
42 #define ABB_READ_REG(reg) { \ |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
43 SPI_WRITE_TX_MSB(reg | 1) \ |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
44 SPI_START_READ } |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
45 |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
46 |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
47 #define ABB_SET_PAGE(page) ABB_WRITE_REG(PAGEREG, page) |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
48 |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
49 #define SEVEN_CYCLES_13M_NS 539 |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
50 |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
51 // INLINE FUNCTIONS |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
52 /*-----------------------------------------------------------------------*/ |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
53 /* ABB_SetPage() */ |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
54 /* */ |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
55 /* This function sets the right page in the ABB register PAGEREG. */ |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
56 /* */ |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
57 /*-----------------------------------------------------------------------*/ |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
58 static inline void ABB_SetPage(SYS_UWORD16 page) |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
59 { |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
60 volatile SYS_UWORD16 status; |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
61 |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
62 ABB_SET_PAGE(page); |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
63 while(((status = * (volatile SYS_UWORD16 *) SPI_REG_STATUS) & WE_ST) == 0); |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
64 |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
65 // if IBIC is already processing another request (from the BSP) |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
66 // the USP request is delayed by 3 clock cycles |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
67 // which gives a total of 7 clock cycles ( = 539 ns at 13 MHz) in the worst case |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
68 wait_ARM_cycles(convert_nanosec_to_cycles(SEVEN_CYCLES_13M_NS)); |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
69 } |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
70 |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
71 |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
72 /*-----------------------------------------------------------------------*/ |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
73 /* ABB_WriteRegister() */ |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
74 /* */ |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
75 /* This function writes "data" in the ABB register "abb_reg". */ |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
76 /* */ |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
77 /*-----------------------------------------------------------------------*/ |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
78 static inline void ABB_WriteRegister(SYS_UWORD16 abb_reg, SYS_UWORD16 data) |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
79 { |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
80 volatile SYS_UWORD16 status; |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
81 |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
82 ABB_WRITE_REG(abb_reg, data); |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
83 while(((status = * (volatile SYS_UWORD16 *) SPI_REG_STATUS) & WE_ST) == 0); |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
84 |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
85 // if IBIC is already processing another request (from the BSP) |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
86 // the USP request is delayed by 3 clock cycles |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
87 // which gives a total of 7 clock cycles ( = 539 ns at 13 MHz) in the worst case |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
88 wait_ARM_cycles(convert_nanosec_to_cycles(SEVEN_CYCLES_13M_NS)); |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
89 |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
90 } |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
91 |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
92 |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
93 /*-----------------------------------------------------------------------*/ |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
94 /* ABB_ReadRegister() */ |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
95 /* */ |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
96 /* This function reads the ABB register "abb_reg" and returns */ |
587
cc0944d35698
gsm-fw/bsp/abb+spi/*.h: formatting fixes (line length and tabs)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
97 /* the real register value. */ |
148
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
98 /* */ |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
99 /*-----------------------------------------------------------------------*/ |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
100 static inline SYS_UWORD16 ABB_ReadRegister(SYS_UWORD16 abb_reg) |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
101 { |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
102 volatile SYS_UWORD16 status; |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
103 |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
104 // First part of read access to the ABB register |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
105 ABB_READ_REG(abb_reg); |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
106 while(((status = * (volatile SYS_UWORD16 *) SPI_REG_STATUS) & RE_ST) == 0); |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
107 |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
108 // if IBIC is already processing another request (from the BSP) |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
109 // the USP request is delayed by 3 clock cycles |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
110 // which gives a total of 7 clock cycles ( = 539 ns at 13 MHz) in the worst case |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
111 wait_ARM_cycles(convert_nanosec_to_cycles(SEVEN_CYCLES_13M_NS)); |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
112 |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
113 // Second part of read access to the ABB register |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
114 ABB_READ_REG(abb_reg); |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
115 while(((status = * (volatile SYS_UWORD16 *) SPI_REG_STATUS) & RE_ST) == 0); |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
116 |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
117 // if IBIC is already processing another request (from the BSP) |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
118 // the USP request is delayed by 3 clock cycles |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
119 // which gives a total of 7 clock cycles ( = 539 ns at 13 MHz) in the worst case |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
120 wait_ARM_cycles(convert_nanosec_to_cycles(SEVEN_CYCLES_13M_NS)); |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
121 |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
122 return ((SPI_ReadRX_LSB() >> 6) & 0x3ff); |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
123 } |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
124 |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
125 |
63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
126 #endif // __ABB_INLINE_H__ |