Nordic Semiconductor nRF5 AirFuel SDK  version 2.2.0
pru_hal_evkit.c
Go to the documentation of this file.
1 /* Copyright (c) Nordic Semiconductor. All Rights Reserved.
2  *
3  * The information contained herein is property of Nordic Semiconductor ASA.
4  * Terms and conditions of usage are described in detail in NORDIC
5  * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
6  *
7  * Licensees are granted free, non-transferable use of the information. NO
8  * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
9  * the file.
10  *
11  */
12 
18 #include <stdbool.h>
19 #include <stdint.h>
20 
21 #include "nrf_error.h"
22 #include "pru_hw_config.h"
23 #include "pru_hal.h"
24 
25 #define VRECT_DEFAULT_VAL 0
26 #define IRECT_DEFAULT_VAL 100
27 #define VOUT_DEFAULT_VAL 2000
28 #define IOUT_DEFAULT_VAL 100
29 #define TEMP_DEFAULT_VAL 20
31 /******************************************************************************/
32 
34 /******************************************************************************/
35 
36 static uint32_t m_vrect;
37 static uint32_t m_irect;
38 static uint32_t m_vout;
39 static uint32_t m_iout;
40 static int16_t m_temp;
42 static bool m_charge_complete;
43 static bool m_vout_enable;
45 static bool m_power_adjusted;
49 /******************************************************************************/
52 /******************************************************************************/
53 
54 uint32_t pru_hal_init(void)
55 {
56  // Set default values
63  m_charge_complete = false;
64  m_vout_enable = false;
66  m_power_adjusted = false;
67 
68  return NRF_SUCCESS;
69 }
70 
71 uint32_t pru_hal_vrect_get(uint16_t * p_vrect)
72 {
73  *p_vrect = m_vrect;
74  return NRF_SUCCESS;
75 }
76 
77 uint32_t pru_hal_irect_get(uint16_t * p_irect)
78 {
79  *p_irect = m_irect;
80  return NRF_SUCCESS;
81 }
82 
83 uint32_t pru_hal_vout_enable_set(bool enable)
84 {
85  m_vout_enable = enable;
86  return NRF_SUCCESS;
87 }
88 
89 uint32_t pru_hal_vout_enable_get(bool * enable)
90 {
91  *enable = m_vout_enable;
92  return NRF_SUCCESS;
93 }
94 
95 uint32_t pru_hal_vout_get(uint16_t * p_vout)
96 {
97  *p_vout = m_vout;
98  return NRF_SUCCESS;
99 }
100 
101 uint32_t pru_hal_iout_get(uint16_t * p_iout)
102 {
103  *p_iout = m_iout;
104  return NRF_SUCCESS;
105 }
106 
107 uint32_t pru_hal_temperature_get(int16_t * p_temperature)
108 {
109  *p_temperature = m_temp;
110  return NRF_SUCCESS;
111 }
112 
114 {
115  *p_wired = m_wired_charge_detected;
116  return NRF_SUCCESS;
117 }
118 
119 uint32_t pru_hal_charge_complete_status_get(bool * p_charge_complete)
120 {
121  *p_charge_complete = m_charge_complete;
122  return NRF_SUCCESS;
123 }
124 
126 {
127  m_power_adj = adj_setting;
128  return NRF_SUCCESS;
129 }
130 
131 uint32_t pru_hal_adj_power_get(ctl_adj_power_t * adj_setting)
132 {
133  *adj_setting = m_power_adj;
134  return NRF_SUCCESS;
135 }
136 
137 uint32_t pru_hal_power_adjusted_get(bool * adjusted)
138 {
139  *adjusted = m_power_adjusted;
140  return NRF_SUCCESS;
141 }
142 
143 uint32_t pru_hal_power_adjusted_set(bool adjusted)
144 {
145  m_power_adjusted = adjusted;
146  return NRF_SUCCESS;
147 }
148 
static uint32_t m_vout
Definition: pru_hal_evkit.c:38
static uint32_t m_vrect
Definition: pru_hal_evkit.c:36
#define VOUT_DEFAULT_VAL
Definition: pru_hal_evkit.c:27
#define IRECT_DEFAULT_VAL
Definition: pru_hal_evkit.c:26
static uint32_t m_irect
Definition: pru_hal_evkit.c:37
#define VRECT_DEFAULT_VAL
Definition: pru_hal_evkit.c:25
uint32_t pru_hal_wired_charge_detect_status_get(bool *p_wired)
Get the status of whether the PRU is charged by wire.
static ctl_adj_power_t m_power_adj
Definition: pru_hal_evkit.c:44
uint32_t pru_hal_temperature_get(int16_t *p_temperature)
Read the temperature.
static bool m_power_adjusted
Definition: pru_hal_evkit.c:45
uint32_t pru_hal_power_adjusted_set(bool adjusted)
Set power adjusted value.
uint32_t pru_hal_vout_get(uint16_t *p_vout)
Read the voltage output to battery.
Definition: pru_hal_evkit.c:95
uint32_t pru_hal_vrect_get(uint16_t *p_vrect)
Read the value of VRECT.
Definition: pru_hal_evkit.c:71
#define TEMP_DEFAULT_VAL
Definition: pru_hal_evkit.c:29
static int16_t m_temp
Definition: pru_hal_evkit.c:40
uint32_t pru_hal_adj_power_set(ctl_adj_power_t adj_setting)
Limit maximum power consumed by PRU.
uint32_t pru_hal_charge_complete_status_get(bool *p_charge_complete)
Get the status of whether the PRU is charged.
uint32_t pru_hal_vout_enable_get(bool *enable)
Get status of VOUT enable.
Definition: pru_hal_evkit.c:89
static bool m_wired_charge_detected
Definition: pru_hal_evkit.c:41
uint32_t pru_hal_irect_get(uint16_t *p_irect)
Read the value of IRECT.
Definition: pru_hal_evkit.c:77
#define IOUT_DEFAULT_VAL
Definition: pru_hal_evkit.c:28
uint32_t pru_hal_init(void)
Initialize the PRU's Hardware abstraction layer.
Definition: pru_hal_evkit.c:54
static uint32_t m_iout
Definition: pru_hal_evkit.c:39
uint32_t pru_hal_adj_power_get(ctl_adj_power_t *adj_setting)
Get adjust power setting.
ctl_adj_power_t
Power adjust settings in control packet.
Definition: wpt.h:42
uint32_t pru_hal_vout_enable_set(bool enable)
Enable output to battery.
Definition: pru_hal_evkit.c:83
uint32_t pru_hal_iout_get(uint16_t *p_iout)
Read the value of IOUT.
uint32_t pru_hal_power_adjusted_get(bool *adjusted)
This function is called by the PRU profile to see if the PRU has limited its power consumption as ins...
static bool m_vout_enable
Definition: pru_hal_evkit.c:43
static bool m_charge_complete
Definition: pru_hal_evkit.c:42