FreeCalypso > hg > fc-magnetite
comparison src/cs/drivers/drv_core/abb/abb.c @ 327:d7b25dca1266
.../drv_core/abb/abb.c: don't set backup battery bits in BCICONF
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 08 Dec 2017 03:05:19 +0000 |
parents | 945cf7f506b2 |
children | 337e6d3a4454 |
comparison
equal
deleted
inserted
replaced
326:919b44c991fc | 327:d7b25dca1266 |
---|---|
73 | 73 |
74 #if (RF_FAM == 2) | 74 #if (RF_FAM == 2) |
75 #include "l1_rf2.h" | 75 #include "l1_rf2.h" |
76 #endif | 76 #endif |
77 | 77 |
78 /* | |
79 * The following conditional compilation control is a FreeCalypso addition. | |
80 * TI's original code always configured the BCICONF register with | |
81 * MESBB and BBCHGEN bits set, enabling both charging and the measurement | |
82 * resistive divider for the backup battery. However, on our primary | |
83 * hw targets (Openmoko GTA02 and our own FCDEV3B) Iota's VBACKUP pin | |
84 * is unconnected, whereas on Mot C139 and Pirelli DP-L10 "alien" hw | |
85 * the VBACKUP situation is unclear. But at least on our known hw | |
86 * with VBACKUP unconnected, it is better to leave backup battery charging | |
87 * and measurement OFF - TI's original config seems to be a drain on | |
88 * the main battery. Therefore, we are going to leave MESBB and BBCHGEN | |
89 * off until and unless we have a hw target where backup battery charging | |
90 * and measurement are appropriate. | |
91 */ | |
92 | |
93 #define ENABLE_BACKUP_BATTERY 0 | |
94 | |
78 #if (ABB_SEMAPHORE_PROTECTION) | 95 #if (ABB_SEMAPHORE_PROTECTION) |
79 | 96 |
80 static NU_SEMAPHORE abb_sem; | 97 static NU_SEMAPHORE abb_sem; |
81 | 98 |
82 /*-----------------------------------------------------------------------*/ | 99 /*-----------------------------------------------------------------------*/ |
505 // This transmission disables TAPREG access. | 522 // This transmission disables TAPREG access. |
506 ABB_WriteRegister(TAPCTRL, 0x00); | 523 ABB_WriteRegister(TAPCTRL, 0x00); |
507 | 524 |
508 // enable BB battery charge BCICONF register, enable test mode to track BDLEN and BULEN windows | 525 // enable BB battery charge BCICONF register, enable test mode to track BDLEN and BULEN windows |
509 // This transmission enables BB charge and BB bridge connection for BB measurements. | 526 // This transmission enables BB charge and BB bridge connection for BB measurements. |
510 ABB_WriteRegister(BCICONF, 0x060); | 527 #if ENABLE_BACKUP_BATTERY |
528 ABB_WriteRegister(BCICONF, 0x060); | |
529 #else | |
530 ABB_WriteRegister(BCICONF, 0x000); | |
531 #endif | |
511 | 532 |
512 /* ************************ SELECTION OF BBCFG CONFIG FOR ABB 3 PG2_0 *******************************/ | 533 /* ************************ SELECTION OF BBCFG CONFIG FOR ABB 3 PG2_0 *******************************/ |
513 #if (ANLG_FAM == 3) | 534 #if (ANLG_FAM == 3) |
514 #if (ANLG_PG == S_PG_20) // SYREN PG2.0 ON EVACONSO | 535 #if (ANLG_PG == S_PG_20) // SYREN PG2.0 ON EVACONSO |
515 ABB_WriteRegister(BBCFG, C_BBCFG); // Initialize transmit register | 536 ABB_WriteRegister(BBCFG, C_BBCFG); // Initialize transmit register |
788 ABB_WriteRegister(AFCCTLADD, reg_val); | 809 ABB_WriteRegister(AFCCTLADD, reg_val); |
789 | 810 |
790 // Set AFCOUT to 0. | 811 // Set AFCOUT to 0. |
791 ABB_WriteRegister(AFCOUT, 0x00); | 812 ABB_WriteRegister(AFCOUT, 0x00); |
792 | 813 |
814 #if ENABLE_BACKUP_BATTERY | |
793 // Read BCICONF value and cut the measurement bridge of BB cut the BB charge. | 815 // Read BCICONF value and cut the measurement bridge of BB cut the BB charge. |
794 reg_val = ABB_ReadRegister(BCICONF) & 0x039f; | 816 reg_val = ABB_ReadRegister(BCICONF) & 0x039f; |
795 | 817 |
796 ABB_WriteRegister(BCICONF, reg_val); | 818 ABB_WriteRegister(BCICONF, reg_val); |
819 #endif | |
797 | 820 |
798 // Disable the ABB test mode | 821 // Disable the ABB test mode |
799 ABB_WriteRegister(TAPCTRL, 0x00); | 822 ABB_WriteRegister(TAPCTRL, 0x00); |
800 | 823 |
801 ABB_SetPage(PAGE0); | 824 ABB_SetPage(PAGE0); |
954 // Read AFCCTLADD register value and disable USP access to AFCOUT register. | 977 // Read AFCCTLADD register value and disable USP access to AFCOUT register. |
955 reg_val = ABB_ReadRegister(AFCCTLADD) & ~0x04; | 978 reg_val = ABB_ReadRegister(AFCCTLADD) & ~0x04; |
956 | 979 |
957 ABB_WriteRegister(AFCCTLADD, reg_val); | 980 ABB_WriteRegister(AFCCTLADD, reg_val); |
958 | 981 |
982 #if ENABLE_BACKUP_BATTERY | |
959 // Read BCICONF register value and enable BB measurement bridge enable BB charge. | 983 // Read BCICONF register value and enable BB measurement bridge enable BB charge. |
960 reg_val = ABB_ReadRegister(BCICONF) | 0x0060; | 984 reg_val = ABB_ReadRegister(BCICONF) | 0x0060; |
961 | 985 |
962 ABB_WriteRegister(BCICONF, reg_val); | 986 ABB_WriteRegister(BCICONF, reg_val); |
987 #endif | |
963 | 988 |
964 | 989 |
965 /* *************************************************************************************************** */ | 990 /* *************************************************************************************************** */ |
966 // update the Delay needed by the ABB before going in deep sleep, and clear previous delay value. | 991 // update the Delay needed by the ABB before going in deep sleep, and clear previous delay value. |
967 reg_val = ABB_ReadRegister(VRPCCFG) & 0x1e0; | 992 reg_val = ABB_ReadRegister(VRPCCFG) & 0x1e0; |