Merge git://github.com/r0ket/r0ket

This commit is contained in:
bernd 2011-08-04 14:16:12 +02:00
commit cf7602a388
6 changed files with 64 additions and 16 deletions

View File

@ -42,13 +42,13 @@ void queue_unsetinvert(void){
#define EVERY(x,y) if((ctr+y)%(x/SYSTICKSPEED)==0)
// every 10 ms
// every SYSTICKSPEED ms
void tick_default(void) {
static int ctr;
ctr++;
incTimer();
EVERY(1000,0){
EVERY(1024,0){
if(!adcMutex){
VoltageCheck();
LightCheck();
@ -58,7 +58,7 @@ void tick_default(void) {
};
static char night=0;
EVERY(100,2){
EVERY(128,2){
if(night!=isNight()){
night=isNight();
if(night){
@ -82,5 +82,9 @@ void tick_default(void) {
gpioSetValue (RB_LED3, 0);
};
};
EVERY(4096,17){
nrf_check_reset();
};
return;
};

View File

@ -70,7 +70,7 @@ void init(void)
void mount(void)
{
int res;
lcdPrintln("Mount DF:");
lcdPrint("Mount:");
res=f_mount(0, &FatFs);
lcdPrintln(f_get_rc_string(res));
lcdRefresh();
@ -79,7 +79,8 @@ void mount(void)
void format(void)
{
int res;
lcdPrintln("Formatting DF...");
lcdPrintln("Format DF:");
res=f_mount(0, &FatFs);
res=f_mkfs(0,1,0);
lcdPrintln(f_get_rc_string(res));
lcdRefresh();
@ -91,29 +92,34 @@ int check(void)
int res = 1;
res=f_open(&file, "flashed.cfg", FA_OPEN_EXISTING|FA_READ);
lcdPrint("open:");
lcdPrintln(f_get_rc_string(res));
lcdPrint(f_get_rc_string(res));
lcdPrintln(" ");
lcdRefresh();
return res;
}
void msc(int timeout)
{
lcdPrintln("MSC Enabled.");
lcdPrintln("MSC: Wait4data...");
lcdRefresh();
delayms_power(300);
usbMSCInit();
while(check()){
while(1){
lcdSetCrsr(0,3*8);
mount();
if(!check())
break;
if(getInputRaw())
break;
delayms(100);
f_recv();
lcdRefresh();
}
while(timeout--){
//f_recv();
delayms(100);
}
lcdPrintln("MSC Disabled.");
lcdPrintln("MSC:Off.");
usbMSCOff();
lcdRefresh();
}
@ -127,11 +133,13 @@ void isp(void)
void main_initial(void) {
init();
mount();
//if( check() )
format();
msc(5);
delayms(200);
lcdPrintln("ISP:ON");
lcdPrintln("turn off");
lcdPrintln("when done.");
lcdRefresh();
ReinvokeISP();
}

View File

@ -191,8 +191,7 @@ int nrf_rcv_pkt_time_encr(int maxtime, int maxsize, uint8_t * pkt, uint32_t cons
#define LOOPY 10
for (;maxtime >= LOOPY;maxtime-=LOOPY){
delayms(LOOPY);
// status =nrf_cmd_status(C_NOP);
CS_LOW(); status=C_NOP; sspSendReceive(0, &status, 1); CS_HIGH();
status =nrf_cmd_status(C_NOP);
if( (status & R_STATUS_RX_DR) == R_STATUS_RX_DR){
if( (status & R_STATUS_RX_P_NO) == R_STATUS_RX_FIFO_EMPTY){
nrf_cmd(C_FLUSH_RX);
@ -392,6 +391,9 @@ void nrf_init() {
// Set speed / strength
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() {
@ -401,3 +403,13 @@ void nrf_off() {
R_CONFIG_MASK_MAX_RT
); // 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;
};

View File

@ -162,7 +162,10 @@ void nrf_set_strength(unsigned char strength);
void nrf_rcv_pkt_start(void);
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]);
// more utility.
void nrf_rcv_pkt_end(void);
uint8_t nrf_check_reset(void);
/* END */

View File

@ -67,3 +67,8 @@ uint32touint8p
uint8ptouint32
memset
nrf_config_set
nrf_read_reg
nrf_check_reset
sspSend
sspReceive
sspSendReceive

View File

@ -11,12 +11,13 @@
#include "core/iap/iap.h"
#include "funk/nrf24l01p.h"
#include "funk/mesh.h"
#include "usetable.h"
/**************************************************************************/
void ChkFlame(void);
void ChkFunk(void);
void ChkLight(void);
void ChkBattery(void);
void m_time(void);
@ -29,6 +30,7 @@ static const struct MENU submenu_debug={ "debug", {
{ "ChkBattery", &ChkBattery},
{ "ChkLight", &ChkLight},
{ "MeshInfo", &m_time},
{ "ChkFunk", &ChkFunk},
{ "Qstatus", &Qstatus},
{ "ShowSP", &getsp},
{ "Uptime", &uptime},
@ -226,3 +228,17 @@ void m_time(void){
delayms_queue(50);
}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();
};