Browse Source

recode

master
zhaohe 1 year ago
parent
commit
efdb1b55c3
  1. 19
      include/znordic.h
  2. 22
      src/znordic.c

19
include/sys.h → include/znordic.h

@ -19,7 +19,12 @@
#include "nrf_ble_qwr.h"
#include "nrf_block_dev_sdc.h"
#include "nrf_delay.h"
#include "nrf_drv_pwm.h"
#include "nrf_drv_saadc.h"
#include "nrf_drv_spi.h"
#include "nrf_drv_twi.h"
#include "nrf_drv_wdt.h"
#include "nrf_gpio.h"
#include "nrf_log.h"
#include "nrf_log_ctrl.h"
#include "nrf_log_default_backends.h"
@ -31,8 +36,18 @@
//
#define APP_BLE_CONN_CFG_TAG 1 /**< A tag identifying the SoftDevice BLE configuration. */
void zsys_init();
void zsys_loop();
/*******************************************************************************
* UTILS *
*******************************************************************************/
void znordic_init();
void znordic_loop();
void znrf_gpio_cfg_output(uint32_t pin_number, nrf_gpio_pin_pull_t pull);
int16_t znrf_adc_channel_read_val(uint16_t channel);
/*******************************************************************************
* LOG *
*******************************************************************************/
#define ZLOGI(...) NRF_LOG_INFO(__VA_ARGS__)
#define ZLOGE(...) NRF_LOG_ERROR(__VA_ARGS__)

22
src/sys.c → src/znordic.c

@ -1,5 +1,5 @@
#include "sys.h"
void zsys_init() {
#include "znordic.h"
void znordic_init() {
{
/*******************************************************************************
* *
@ -42,10 +42,26 @@ void zsys_init() {
}
}
void zsys_loop() {
void znordic_loop() {
while (true) {
if (NRF_LOG_PROCESS() == false) {
nrf_pwr_mgmt_run();
}
}
}
void znrf_gpio_cfg_output(uint32_t pin_number, nrf_gpio_pin_pull_t pull) { //
nrf_gpio_cfg(pin_number, NRF_GPIO_PIN_DIR_OUTPUT, NRF_GPIO_PIN_INPUT_DISCONNECT, pull, NRF_GPIO_PIN_S0S1, NRF_GPIO_PIN_NOSENSE);
}
int16_t znrf_adc_channel_read_val(uint16_t channel) {
nrf_saadc_value_t value;
ret_code_t err_code;
err_code = nrfx_saadc_sample_convert(channel, &value);
if (err_code != NRF_SUCCESS) {
ZLOGE("nrfx_saadc_sample_convert(%d) fail err_code:%d", channel, err_code);
return 0;
}
return value;
}
Loading…
Cancel
Save