Add nrf_check_reset, and run it every 5 seconds.
Also: add more debugging
This commit is contained in:
parent
55d15269c5
commit
64d22980f2
|
@ -42,13 +42,13 @@ void queue_unsetinvert(void){
|
||||||
|
|
||||||
#define EVERY(x,y) if((ctr+y)%(x/SYSTICKSPEED)==0)
|
#define EVERY(x,y) if((ctr+y)%(x/SYSTICKSPEED)==0)
|
||||||
|
|
||||||
// every 10 ms
|
// every SYSTICKSPEED ms
|
||||||
void tick_default(void) {
|
void tick_default(void) {
|
||||||
static int ctr;
|
static int ctr;
|
||||||
ctr++;
|
ctr++;
|
||||||
incTimer();
|
incTimer();
|
||||||
|
|
||||||
EVERY(1000,0){
|
EVERY(1024,0){
|
||||||
if(!adcMutex){
|
if(!adcMutex){
|
||||||
VoltageCheck();
|
VoltageCheck();
|
||||||
LightCheck();
|
LightCheck();
|
||||||
|
@ -58,7 +58,7 @@ void tick_default(void) {
|
||||||
};
|
};
|
||||||
|
|
||||||
static char night=0;
|
static char night=0;
|
||||||
EVERY(100,2){
|
EVERY(128,2){
|
||||||
if(night!=isNight()){
|
if(night!=isNight()){
|
||||||
night=isNight();
|
night=isNight();
|
||||||
if(night){
|
if(night){
|
||||||
|
@ -82,5 +82,9 @@ void tick_default(void) {
|
||||||
gpioSetValue (RB_LED3, 0);
|
gpioSetValue (RB_LED3, 0);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
EVERY(4096,17){
|
||||||
|
nrf_check_reset();
|
||||||
|
};
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
|
@ -191,8 +191,7 @@ int nrf_rcv_pkt_time_encr(int maxtime, int maxsize, uint8_t * pkt, uint32_t cons
|
||||||
#define LOOPY 10
|
#define LOOPY 10
|
||||||
for (;maxtime >= LOOPY;maxtime-=LOOPY){
|
for (;maxtime >= LOOPY;maxtime-=LOOPY){
|
||||||
delayms(LOOPY);
|
delayms(LOOPY);
|
||||||
// status =nrf_cmd_status(C_NOP);
|
status =nrf_cmd_status(C_NOP);
|
||||||
CS_LOW(); status=C_NOP; sspSendReceive(0, &status, 1); CS_HIGH();
|
|
||||||
if( (status & R_STATUS_RX_DR) == R_STATUS_RX_DR){
|
if( (status & R_STATUS_RX_DR) == R_STATUS_RX_DR){
|
||||||
if( (status & R_STATUS_RX_P_NO) == R_STATUS_RX_FIFO_EMPTY){
|
if( (status & R_STATUS_RX_P_NO) == R_STATUS_RX_FIFO_EMPTY){
|
||||||
nrf_cmd(C_FLUSH_RX);
|
nrf_cmd(C_FLUSH_RX);
|
||||||
|
@ -392,6 +391,9 @@ void nrf_init() {
|
||||||
|
|
||||||
// Set speed / strength
|
// Set speed / strength
|
||||||
nrf_write_reg(R_RF_SETUP,DEFAULT_SPEED|R_RF_SETUP_RF_PWR_3);
|
nrf_write_reg(R_RF_SETUP,DEFAULT_SPEED|R_RF_SETUP_RF_PWR_3);
|
||||||
|
|
||||||
|
// Clear MAX_RT, just in case.
|
||||||
|
nrf_write_reg(R_STATUS,R_STATUS_MAX_RT);
|
||||||
};
|
};
|
||||||
|
|
||||||
void nrf_off() {
|
void nrf_off() {
|
||||||
|
@ -401,3 +403,13 @@ void nrf_off() {
|
||||||
R_CONFIG_MASK_MAX_RT
|
R_CONFIG_MASK_MAX_RT
|
||||||
); // Most important: no R_CONFIG_PWR_UP
|
); // Most important: no R_CONFIG_PWR_UP
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
uint8_t nrf_check_reset(void){
|
||||||
|
static uint8_t _nrfresets=0;
|
||||||
|
if(nrf_cmd_status(C_NOP) & R_STATUS_MAX_RT){
|
||||||
|
_nrfresets++;
|
||||||
|
nrf_init();
|
||||||
|
};
|
||||||
|
return _nrfresets;
|
||||||
|
};
|
||||||
|
|
|
@ -162,7 +162,10 @@ void nrf_set_strength(unsigned char strength);
|
||||||
void nrf_rcv_pkt_start(void);
|
void nrf_rcv_pkt_start(void);
|
||||||
int nrf_rcv_pkt_poll(int maxsize, uint8_t * pkt);
|
int nrf_rcv_pkt_poll(int maxsize, uint8_t * pkt);
|
||||||
int nrf_rcv_pkt_poll_dec(int maxsize, uint8_t * pkt, uint32_t const key[4]);
|
int nrf_rcv_pkt_poll_dec(int maxsize, uint8_t * pkt, uint32_t const key[4]);
|
||||||
|
|
||||||
|
// more utility.
|
||||||
void nrf_rcv_pkt_end(void);
|
void nrf_rcv_pkt_end(void);
|
||||||
|
uint8_t nrf_check_reset(void);
|
||||||
|
|
||||||
/* END */
|
/* END */
|
||||||
|
|
||||||
|
|
|
@ -67,3 +67,8 @@ uint32touint8p
|
||||||
uint8ptouint32
|
uint8ptouint32
|
||||||
memset
|
memset
|
||||||
nrf_config_set
|
nrf_config_set
|
||||||
|
nrf_read_reg
|
||||||
|
nrf_check_reset
|
||||||
|
sspSend
|
||||||
|
sspReceive
|
||||||
|
sspSendReceive
|
||||||
|
|
|
@ -11,12 +11,13 @@
|
||||||
|
|
||||||
#include "core/iap/iap.h"
|
#include "core/iap/iap.h"
|
||||||
|
|
||||||
|
#include "funk/nrf24l01p.h"
|
||||||
#include "funk/mesh.h"
|
#include "funk/mesh.h"
|
||||||
|
|
||||||
#include "usetable.h"
|
#include "usetable.h"
|
||||||
|
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
void ChkFlame(void);
|
void ChkFunk(void);
|
||||||
void ChkLight(void);
|
void ChkLight(void);
|
||||||
void ChkBattery(void);
|
void ChkBattery(void);
|
||||||
void m_time(void);
|
void m_time(void);
|
||||||
|
@ -29,6 +30,7 @@ static const struct MENU submenu_debug={ "debug", {
|
||||||
{ "ChkBattery", &ChkBattery},
|
{ "ChkBattery", &ChkBattery},
|
||||||
{ "ChkLight", &ChkLight},
|
{ "ChkLight", &ChkLight},
|
||||||
{ "MeshInfo", &m_time},
|
{ "MeshInfo", &m_time},
|
||||||
|
{ "ChkFunk", &ChkFunk},
|
||||||
{ "Qstatus", &Qstatus},
|
{ "Qstatus", &Qstatus},
|
||||||
{ "ShowSP", &getsp},
|
{ "ShowSP", &getsp},
|
||||||
{ "Uptime", &uptime},
|
{ "Uptime", &uptime},
|
||||||
|
@ -226,3 +228,17 @@ void m_time(void){
|
||||||
delayms_queue(50);
|
delayms_queue(50);
|
||||||
}while ((getInputRaw())==BTN_NONE);
|
}while ((getInputRaw())==BTN_NONE);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void ChkFunk(){
|
||||||
|
lcdPrint("st: ");
|
||||||
|
lcdPrintln(IntToStrX(nrf_read_reg(R_STATUS),2));
|
||||||
|
lcdPrint("fifost:");
|
||||||
|
lcdPrintln(IntToStrX(nrf_read_reg(R_FIFO_STATUS),2));
|
||||||
|
lcdPrint("cfg:");
|
||||||
|
lcdPrintln(IntToStrX(nrf_read_reg(R_CONFIG),2));
|
||||||
|
lcdPrintln("Resets:");
|
||||||
|
lcdPrintln(IntToStr(nrf_check_reset(),3,0));
|
||||||
|
lcdRefresh();
|
||||||
|
while(!getInputRaw())work_queue();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue