annotate gsm-fw/bsp/abb+spi/abb_inth.c @ 148:63750f70796d

gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sat, 16 Nov 2013 19:03:37 +0000
parents
children 1c0033c2fe33
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
148
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 /**********************************************************************************/
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
2 /* TEXAS INSTRUMENTS INCORPORATED PROPRIETARY INFORMATION */
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
3 /* */
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4 /* Property of Texas Instruments -- For Unrestricted Internal Use Only */
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5 /* Unauthorized reproduction and/or distribution is strictly prohibited. This */
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6 /* product is protected under copyright law and trade secret law as an */
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7 /* unpublished work. Created 1987, (C) Copyright 1997 Texas Instruments. All */
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8 /* rights reserved. */
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
9 /* */
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
10 /* */
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
11 /* Filename : abb_inth.c */
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
12 /* */
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13 /* Description : Functions to manage the ABB device interrupt. */
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
14 /* The Serial Port Interface is used to connect the TI */
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
15 /* Analog BaseBand (ABB). */
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
16 /* It is assumed that the ABB is connected as the SPI */
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
17 /* device 0, and ABB interrupt is mapped as external IT. */
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
18 /* */
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
19 /* Author : Pascal PUEL */
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
20 /* */
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
21 /* Version number : 1.2 */
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
22 /* */
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
23 /* Date and time : 07/02/03 */
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
24 /* */
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
25 /* Previous delta : Creation */
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
26 /* */
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
27 /**********************************************************************************/
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 /* 17/12/03 */
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
30 /* The original abb_inth.c has been splitted between the actual abb_inth.c */
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
31 /* located in drv_apps directory and abb_inth_core.c located in drv_core */
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
32 /* directory. */
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
33 /* */
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
34 /**********************************************************************************/
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
35
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
36 #include "l1sw.cfg"
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
37 #include "chipset.cfg"
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
38 #include "swconfig.cfg"
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
39 #include "sys.cfg"
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
40
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 #include "l1_macro.h"
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
43 #include "l1_confg.h"
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
44 #include <string.h>
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
45 #include "abb/abb_inth.h"
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
46 #include "nucleus.h"
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
47
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
48 #include "rv/rv_defined_swe.h" // for RVM_PWR_SWE
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
49
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
50 #if (CHIPSET == 12)
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
51 #include "sys_inth.h"
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
52 #else
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
53 #include "inth/iq.h"
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
54 #endif
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
55
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
56 #include "cust_os.h"
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
57 #include "l1_signa.h"
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
58 #include "abb/abb.h"
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 #if defined (OP_WCP)
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
61 #include "ffs/ffs.h"
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
62 #include "ffs/board/ffspcm.h"
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
63 #endif
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 #include "rvm/rvm_use_id_list.h" // for SPI_USE_ID
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
66 #include "spi/spi_env.h"
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
67 #include "spi/spi_process.h" // for ABB_EXT_IRQ_EVT
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
68 #include "kpd/kpd_power_api.h" // for kpd_power_key_pressed()
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
69 #include "power/power.h"
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 #ifdef RVM_LCC_SWE
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
73 #include "lcc/lcc_api.h"
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
74 #include "lcc/lcc_cfg_i.h"
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
75 #include "lcc/lcc.h"
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
76 #include "lcc/lcc_env.h"
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
77 #endif
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
78 /********************************************************************************/
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 /* Function Name: spi_abb_read_int_reg_callback */
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 /* Purpose: Callback function */
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
83 /* Called when an external interrupt has occured and the */
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
84 /* ABB interrupt register has been read. */
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
85 /* */
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
86 /********************************************************************************/
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
87 void spi_abb_read_int_reg_callback(SYS_UWORD16 *read_value)
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
88 {
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
89 SYS_UWORD16 loop_count;
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
90 SYS_UWORD16 status_value;
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
91 xSignalHeaderRec *adc_msg;
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
92 volatile SYS_UWORD8 i;
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 #ifdef RVM_LCC_SWE
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
95 struct pwr_adc_ind_s *addr;
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
96 extern T_PWR_CTRL_BLOCK *pwr_ctrl;
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
97 #endif
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 // check all the possible causes of the ABB IT
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
101 if (*read_value & PUSHOFF_IT_STS)
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
102 {
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
103 /* Push Button from ON to OFF */
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
104 if (SPI_GBL_INFO_PTR->is_gsm_on == TRUE)
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
105 {
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
106 NU_Sleep(SHORT_OFF_KEY_PRESSED);
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 // WCP Patch
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
109 #if (OP_WCP == 1)
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
110 // Backup of GSM FFS is remotely handled by MPU-S
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
111 // we trigger the backup upon each ON->OFF transition
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
112 ffs_backup ();
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
113 #else
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
114 /* Since this callback function is called from the SPI task
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
115 it can't be interrupted by another task
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
116 so we can directly access the SPI through the low-level driver */
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
117
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
118 #if ((ANLG_FAM == 1) || (ANLG_FAM == 2))
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
119 status_value = (ABB_Read_Status() & ONREFLT);
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
120 #elif (ANLG_FAM == 3)
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
121 status_value = (ABB_Read_Register_on_page(PAGE1, VRPCCFG) & PWOND);
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
122 #endif
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 if (status_value == PWR_OFF_KEY_PRESSED)
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 /* Inform keypad that key ON/OFF has been pressed */
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
127 kpd_power_key_pressed();
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
128
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
129 loop_count = 0;
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
130 /* Wait loop for Power-OFF */
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
131 while ((loop_count < OFF_LOOP_COUNT) &&
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
132 (status_value == PWR_OFF_KEY_PRESSED))
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
133 {
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
134 NU_Sleep(SHORT_OFF_KEY_PRESSED);
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
135 #if ((ANLG_FAM == 1) || (ANLG_FAM == 2))
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
136 status_value = (ABB_Read_Status() & ONREFLT);
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
137 #elif (ANLG_FAM == 3)
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
138 status_value = (ABB_Read_Register_on_page(PAGE1, VRPCCFG) & PWOND);
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
139 #endif
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
140 loop_count++;
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
141 }
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
142
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
143 if (status_value == PWR_OFF_KEY_PRESSED) /* Power-OFF request detected */
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
144 {
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
145 rvf_send_trace("IQ EXT: Power Off request",25, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, SPI_USE_ID);
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
146
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
147 Power_OFF_Button();
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
148 }
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
149 }
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
150 #endif //WCP
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
151 }
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
152 else /* GSM OFF */
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
153 {
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
154 rvf_send_trace("IQ EXT: Power On request",24, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, SPI_USE_ID);
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
155
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
156 Power_ON_Button();
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
157 }
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
158 }
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
159
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
160 else if (*read_value & REMOT_IT_STS)
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
161 {
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
162 rvf_send_trace("IQ EXT: Power Off remote request",32, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, SPI_USE_ID);
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
163
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
164 /* 'Remote Power' from ON to OFF */
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
165 Power_OFF_Remote();
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
166 }
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
167
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
168 else if (*read_value & ADCEND_IT_STS)
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
169 {
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
170 rvf_send_trace("IQ EXT: ADC End",15, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, SPI_USE_ID);
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
171
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
172 /* ADC end of conversion */
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
173 ABB_Read_ADC(&SPI_GBL_INFO_PTR->adc_result[0]);
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
174 adc_msg = os_alloc_sig(sizeof(T_CST_ADC_RESULT));
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
175 if(adc_msg != NULL)
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
176 {
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
177 adc_msg->SignalCode = CST_ADC_RESULT;
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
178
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
179 for(i=0;i<MADC_NUMBER_OF_MEAS;i++)
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
180 {
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
181 ((T_CST_ADC_RESULT *)(adc_msg->SigP))->adc_result[i] = SPI_GBL_INFO_PTR->adc_result[i];
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
182 }
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
183 os_send_sig(adc_msg, RRM1_QUEUE);
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
184 #ifdef RVM_LCC_SWE
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
185 // Send ADC measurement to PWR (LCC) task
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
186 // NOTE that memory is allocated externally in the PWR task
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
187 if (rvf_get_buf(pwr_ctrl->prim_id, sizeof(struct pwr_adc_ind_s), (void *)&addr) == RVF_RED) {
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
188 rvf_send_trace("rvf_get_buf failed",18, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, LCC_USE_ID);
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
189 /* Unmask External interrupt */
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
190 IQ_Unmask(IQ_EXT);
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
191 // rvf_dump_mem();
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
192 return;
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
193 }
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
194 addr->header.msg_id = PWR_ADC_IND;
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
195 addr->header.src_addr_id = SPI_GBL_INFO_PTR->addr_id;
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
196 addr->header.dest_addr_id = pwr_ctrl->addr_id;
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
197 addr->header.callback_func = NULL;
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
198 // FIXME: memcpy from SPI_GBL_INFO_PTR->adc_result - make sure it has not been de-allocated
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
199 memcpy(addr->data, SPI_GBL_INFO_PTR->adc_result, 8*2);
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
200 addr->data[9] = ABB_Read_Status();; // Read & assign ITSTATREG status so we save the polling in PWR task!!
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
201 if (rvf_send_msg(pwr_ctrl->addr_id, addr) != RV_OK) {
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
202 rvf_send_trace("SPI FATAL: Send failed!",23, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, LCC_USE_ID);
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
203 }
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
204 #endif
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
205 }
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
206 }
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
207
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
208 #if (defined(RVM_PWR_SWE) || defined(RVM_LCC_SWE))
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
209 else if (*read_value & CHARGER_IT_STS)
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
210 {
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
211 /* Charger plug IN or OUT */
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
212 #if ((ANLG_FAM == 1) || (ANLG_FAM == 2))
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
213 status_value = ABB_Read_Status();
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
214 #elif (ANLG_FAM == 3)
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
215 status_value = ABB_Read_Register_on_page(PAGE1, VRPCCFG);
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
216 #endif
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
217 if (status_value & CHGPRES)
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
218 {
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
219 rvf_send_trace("IQ EXT: Charger Plug",20, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, SPI_USE_ID);
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
220 #ifdef RVM_PWR_SWE
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
221 PWR_Charger_Plug(); /* charger plugged IN */
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
222 #endif
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
223 #ifdef RVM_LCC_SWE
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
224 // Forward charger plug indication to PWR (LCC) task
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
225 // NOTE that memory is allocated externally in the PWR task
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
226 if (rvf_get_buf(pwr_ctrl->prim_id, sizeof(struct pwr_req_s), (void *)&addr) == RVF_RED) {
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
227 rvf_send_trace("rvf_get_buf failed#1",20, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, LCC_USE_ID);
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
228 rvf_dump_mem();
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
229 }
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
230 addr->header.msg_id = PWR_CHARGER_PLUGGED_IND;
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
231 addr->header.src_addr_id = SPI_GBL_INFO_PTR->addr_id;
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
232 addr->header.dest_addr_id = pwr_ctrl->addr_id;
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
233 addr->header.callback_func = NULL;
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
234 if (rvf_send_msg(pwr_ctrl->addr_id, addr) != RV_OK) {
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
235 rvf_send_trace("SPI FATAL: Send failed!",23, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, LCC_USE_ID);
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
236 }
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
237 #endif
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
238 }
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
239 else
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
240 {
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
241 rvf_send_trace("IQ EXT: Charger Unplug",22, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, SPI_USE_ID);
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
242
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
243 #ifdef RVM_PWR_SWE
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
244 PWR_Charger_Unplug(); /* charger plugged OUT */
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
245 #endif
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
246 #ifdef RVM_LCC_SWE
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
247 // Forward charger unplug indication to PWR (LCC) task
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
248 // NOTE that memory is allocated externally in the PWR task
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
249 if (rvf_get_buf(pwr_ctrl->prim_id, sizeof(struct pwr_req_s), (void *)&addr) == RVF_RED) {
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
250 rvf_send_trace("rvf_get_buf failed#2",20, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, LCC_USE_ID);
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
251 rvf_dump_mem();
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
252 }
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
253 addr->header.msg_id = PWR_CHARGER_UNPLUGGED_IND;
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
254 addr->header.src_addr_id = SPI_GBL_INFO_PTR->addr_id;
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
255 addr->header.dest_addr_id = pwr_ctrl->addr_id;
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
256 addr->header.callback_func = NULL;
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
257 if (rvf_send_msg(pwr_ctrl->addr_id, addr) != RV_OK) {
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
258 rvf_send_trace("SPI FATAL: Send failed!",23, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, LCC_USE_ID);
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
259 }
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
260 #endif
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
261 }
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
262 }
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
263
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
264 #endif /* RVM_PWR_SWE || RVM_LCC_SWE */
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
265
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
266 /* Unmask External interrupt */
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
267 #if (CHIPSET == 12)
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
268 // Unmask ABB ext interrupt
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
269 F_INTH_ENABLE_ONE_IT(C_INTH_ABB_IRQ_IT);
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
270 #else
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
271 // Unmask external (ABB) interrupt
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
272 IQ_Unmask(IQ_EXT);
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
273 #endif
63750f70796d gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
274 }