lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | /*******************************************************************************
|
| 2 | * Copyright (C) 2016, ZIXC Corporation.
|
| 3 | *
|
| 4 | * File Name: hal_led.c
|
| 5 | * File Mark:
|
| 6 | * Description: This file contains the hal layer routines for i2c driver.
|
| 7 | * Others:
|
| 8 | * Version: V1.0
|
| 9 | * Author: yx
|
| 10 | * Date: 2014-07-03
|
| 11 | * History 1:
|
| 12 | * Date:
|
| 13 | * Version:
|
| 14 | * Author:
|
| 15 | * Modification:
|
| 16 | * History 2:
|
| 17 | ******************************************************************************/
|
| 18 |
|
| 19 | /****************************************************************************
|
| 20 | * Include files
|
| 21 | ****************************************************************************/
|
| 22 |
|
| 23 | //#include "drvs_general.h"
|
| 24 | //#include "drvs_i2c.h"
|
| 25 | #include <linux/types.h>
|
| 26 | #include <zx234290.h>
|
| 27 | #include <led.h>
|
xf.li | 6c8fc1e | 2023-08-12 00:11:09 -0700 | [diff] [blame] | 28 | #include <drvs_gpio.h>
|
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 29 | #include "common.h"
|
| 30 | //#include <gpio.h>
|
| 31 |
|
| 32 | /****************************************************************************
|
| 33 | * Local Macros
|
| 34 | ****************************************************************************/
|
| 35 | #define SD1_IO_1V8_EN 0x13c830
|
| 36 | #define REG32(x) (*(volatile u32*)(x))
|
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 37 | /****************************************************************************
|
| 38 | * Local Types
|
| 39 | ****************************************************************************/
|
| 40 |
|
| 41 | /****************************************************************************
|
| 42 | * Local Constants
|
| 43 | ****************************************************************************/
|
| 44 |
|
| 45 |
|
| 46 | /****************************************************************************
|
| 47 | * Function: peripheral_init
|
| 48 | * Description: init the peripheral include pmu\charger\led\lcd etc.
|
| 49 | * Parameters:
|
| 50 | * Input:
|
| 51 | *
|
| 52 | * Output:
|
| 53 | *
|
| 54 | * Returns:
|
| 55 | * int
|
| 56 | *
|
| 57 | *
|
| 58 | * Others:
|
| 59 | ***************************************************************************/
|
| 60 | int peripheral_init(void)
|
| 61 | {
|
| 62 | int ret = 0;
|
| 63 | ret = power_init();
|
| 64 |
|
| 65 | /*led*/
|
| 66 |
|
| 67 | /*lcd*/
|
| 68 |
|
xf.li | 6c8fc1e | 2023-08-12 00:11:09 -0700 | [diff] [blame] | 69 | /* jtag调试 */
|
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 70 | #if 0
|
| 71 | jtag_init();
|
| 72 | #endif
|
| 73 |
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 74 | //#if 0//ref need ldo8 2.85V
|
xf.li | 6c8fc1e | 2023-08-12 00:11:09 -0700 | [diff] [blame] | 75 | #if defined(CONFIG_ZX297520V3E_VEHICLE_DC) || defined(CONFIG_ZX297520V3E_VEHICLE_DC_REF)
|
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 76 | /*set mmc io and vccQ*/
|
| 77 | zx234290_set_ldo8_voltage(VLDOD_1_800);
|
| 78 | zx234290_set_ldo8_sleep_voltage(VLDOD_1_800);
|
| 79 | zx234290_ldo8_enable(1);
|
| 80 |
|
| 81 | REG32(SD1_IO_1V8_EN) |=(1<<1);
|
xf.li | 4e53099 | 2023-04-17 04:35:55 -0700 | [diff] [blame] | 82 | //xf.li@20230412 add for enable GNSS start
|
xf.li | 6c8fc1e | 2023-08-12 00:11:09 -0700 | [diff] [blame] | 83 | /*关闭gps电源*/
|
| 84 | zDrvGpio_SetFunc(GPIO86, GPIO86_GPIO86);
|
| 85 | zDrvGpio_SetDirection(GPIO86, GPIO_OUT);
|
| 86 | zDrvGpio_SetOutputValue(GPIO86, GPIO_LOW);
|
xf.li | 4e53099 | 2023-04-17 04:35:55 -0700 | [diff] [blame] | 87 |
|
| 88 | zDrvGpio_SetFunc(GPIO126,GPIO126_GPIO126);
|
| 89 | zDrvGpio_SetDirection(GPIO126,GPIO_OUT);
|
| 90 | zDrvGpio_SetOutputValue(GPIO126,GPIO_LOW);
|
xf.li | 4e53099 | 2023-04-17 04:35:55 -0700 | [diff] [blame] | 91 | //xf.li@20230412 add for enable GNSS end
|
xf.li | 6c8fc1e | 2023-08-12 00:11:09 -0700 | [diff] [blame] | 92 | #endif
|
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 93 | zx234502_charger_enable();
|
| 94 |
|
| 95 | return ret ;
|
| 96 | }
|
| 97 |
|
| 98 | /****************************************************************************
|
| 99 | * Function: Show_UpdateWait
|
| 100 | * Description: show the logo when the local updataing through lcd/led etc.
|
| 101 | * Parameters:
|
| 102 | * Input:
|
| 103 | *
|
| 104 | * Output:
|
| 105 | *
|
| 106 | *
|
| 107 | * Returns:
|
| 108 | * int
|
| 109 | *
|
| 110 | *
|
| 111 | * Others:
|
| 112 | ***************************************************************************/
|
| 113 | int Show_UpdateWait(void)
|
| 114 | {
|
| 115 | int ret = 0;
|
| 116 | /*led*/
|
| 117 |
|
| 118 | /*lcd*/
|
| 119 | ;
|
| 120 | return ret;
|
| 121 | }
|
| 122 |
|
| 123 | /****************************************************************************
|
| 124 | * Function: Show_UpdateSucc
|
| 125 | * Description: show the logo when the local updataing through lcd/led etc.
|
| 126 | * Parameters:
|
| 127 | * Input:
|
| 128 | *
|
| 129 | * Output:
|
| 130 | *
|
| 131 | *
|
| 132 | * Returns:
|
| 133 | * int
|
| 134 | *
|
| 135 | *
|
| 136 | * Others:
|
| 137 | ***************************************************************************/
|
| 138 | int Show_UpdateSucc(void)
|
| 139 | {
|
| 140 | int ret = 0;
|
| 141 | /*led*/
|
| 142 |
|
| 143 | /*lcd*/
|
| 144 | ;
|
| 145 | return ret;
|
| 146 | }
|
| 147 |
|
| 148 | /****************************************************************************
|
| 149 | * Function: Show_UpdateFail
|
| 150 | * Description: show the logo when the local updataing through lcd/led etc.
|
| 151 | * Parameters:
|
| 152 | * Input:
|
| 153 | *
|
| 154 | * Output:
|
| 155 | *
|
| 156 | *
|
| 157 | * Returns:
|
| 158 | * int
|
| 159 | *
|
| 160 | *
|
| 161 | * Others:
|
| 162 | ***************************************************************************/
|
| 163 | int Show_UpdateFail(void)
|
| 164 | {
|
| 165 | int ret = 0;
|
| 166 | /*led*/
|
| 167 |
|
| 168 | /*lcd*/
|
| 169 | ;
|
| 170 | return ret;
|
| 171 | }
|
| 172 |
|
| 173 | /****************************************************************************
|
| 174 | * Function: Show_LowPower
|
| 175 | * Description: show the logo when the local updataing through lcd/led etc.
|
| 176 | * Parameters:
|
| 177 | * Input:
|
| 178 | *
|
| 179 | * Output:
|
| 180 | *
|
| 181 | *
|
| 182 | * Returns:
|
| 183 | * int
|
| 184 | *
|
| 185 | *
|
| 186 | * Others:
|
| 187 | ***************************************************************************/
|
| 188 | int Show_LowPower(void)
|
| 189 | {
|
| 190 | int ret = 0;
|
| 191 | /*led*/
|
| 192 |
|
| 193 | /*lcd*/
|
| 194 | ;
|
| 195 | return ret;
|
| 196 | }
|
| 197 |
|
| 198 | /****************************************************************************
|
| 199 | * Function: Show_No_Battery
|
| 200 | * Description: show the logo when the local updataing through lcd/led etc.
|
| 201 | * Parameters:
|
| 202 | * Input:
|
| 203 | *
|
| 204 | * Output:
|
| 205 | *
|
| 206 | *
|
| 207 | * Returns:
|
| 208 | * int
|
| 209 | *
|
| 210 | *
|
| 211 | * Others:
|
| 212 | ***************************************************************************/
|
| 213 | int Show_No_Battery(void)
|
| 214 | {
|
| 215 | int ret = 0;
|
| 216 | /*led*/
|
| 217 |
|
| 218 | /*lcd*/
|
| 219 | ;
|
| 220 | return ret;
|
| 221 | }
|
| 222 |
|
| 223 | /****************************************************************************
|
| 224 | * Function: Show_PowerOn_Normal
|
| 225 | * Description: show the logo when the local updataing through lcd/led etc.
|
| 226 | * Parameters:
|
| 227 | * Input:
|
| 228 | *
|
| 229 | * Output:
|
| 230 | *
|
| 231 | *
|
| 232 | * Returns:
|
| 233 | * int
|
| 234 | *
|
| 235 | *
|
| 236 | * Others:
|
| 237 | ***************************************************************************/
|
| 238 | int Show_PowerOn_Normal(void)
|
| 239 | {
|
| 240 | int ret = 0;
|
| 241 | /*led*/
|
| 242 |
|
| 243 | /*lcd*/
|
| 244 | ;
|
| 245 | return ret;
|
| 246 | }
|
| 247 |
|
| 248 | /****************************************************************************
|
| 249 | * Function: Show_PowerOn_Normal
|
| 250 | * Description: show the logo when the local updataing through lcd/led etc.
|
| 251 | * Parameters:
|
| 252 | * Input:
|
| 253 | *
|
| 254 | * Output:
|
| 255 | *
|
| 256 | *
|
| 257 | * Returns:
|
| 258 | * int
|
| 259 | *
|
| 260 | *
|
| 261 | * Others:
|
| 262 | ***************************************************************************/
|
| 263 |
|
| 264 | int Show_PowerOn_Fota(void)
|
| 265 | {
|
| 266 | int ret = 0;
|
| 267 | /*led*/
|
| 268 |
|
| 269 | /*lcd*/
|
| 270 | ;
|
| 271 | return ret;
|
| 272 | }
|
| 273 |
|
| 274 |
|
| 275 | /****************************************************************************
|
| 276 | * Function: Show_Charging
|
| 277 | * Description: show the logo when the local updataing through lcd/led etc.
|
| 278 | * Parameters:
|
| 279 | * Input:
|
| 280 | *
|
| 281 | * Output:
|
| 282 | *
|
| 283 | *
|
| 284 | * Returns:
|
| 285 | * int
|
| 286 | *
|
| 287 | *
|
| 288 | * Others:
|
| 289 | ***************************************************************************/
|
| 290 | int Show_Charging(void)
|
| 291 | {
|
| 292 | int ret = 0;
|
| 293 | /*led*/
|
| 294 |
|
| 295 | /*lcd*/
|
| 296 | ;
|
| 297 | return ret;
|
| 298 | }
|
| 299 |
|
| 300 | /****************************************************************************
|
| 301 | * Function: zx_get_vbat_voltage
|
| 302 | * Description: .
|
| 303 | * Parameters:
|
| 304 | * Input:
|
| 305 | *
|
| 306 | * Output:
|
| 307 | *
|
| 308 | *
|
| 309 | * Returns:
|
| 310 | * int
|
| 311 | *
|
| 312 | *
|
| 313 | * Others:
|
| 314 | ***************************************************************************/
|
| 315 | int zx_get_vbat_voltage(void)
|
| 316 | {
|
| 317 | // int ret = 0;
|
| 318 |
|
| 319 | return zx234290_get_adc1_voltage();
|
| 320 | }
|
| 321 |
|
| 322 | /****************************************************************************
|
| 323 | * Function: zx_get_battery_Status
|
| 324 | * Description:
|
| 325 | * Parameters:
|
| 326 | * Input:
|
| 327 | *
|
| 328 | * Output:
|
| 329 | *
|
| 330 | *
|
| 331 | * Returns:
|
| 332 | * int
|
| 333 | *
|
| 334 | *
|
| 335 | * Others:
|
| 336 | ***************************************************************************/
|
| 337 | unsigned int zx_get_battery_Status(void)
|
| 338 | {
|
| 339 | int ret = 0;
|
| 340 | int boost_flag = 1;
|
| 341 |
|
| 342 | zx234502_battery_status(&boost_flag);
|
| 343 | if(boost_flag){
|
| 344 | return 0;/*battery uninstall*/
|
| 345 | }
|
| 346 | else
|
| 347 | return 1;/*battery install*/
|
| 348 | }
|
| 349 |
|
| 350 |
|
| 351 |
|
| 352 |
|