flash init --- makes them work much better.
resumeMACAsync on each received packet --- no more lockups.
This commit is contained in:
parent
424761f23d
commit
b508d138a8
|
@ -400,6 +400,7 @@ typedef union maca_maskirq_reg_tag
|
|||
|
||||
#define _is_action_complete_interrupt(x) (0 != (maca_irq_acpl & x))
|
||||
#define _is_filter_failed_interrupt(x) (0 != (maca_irq_flt & x))
|
||||
#define _is_checksum_failed_interrupt(x) (0 != (maca_irq_crc & x))
|
||||
|
||||
#define SMAC_MACA_CNTL_INIT_STATE ( control_prm | control_nofc | control_mode_non_slotted )
|
||||
|
||||
|
@ -411,6 +412,7 @@ void init_phy(void);
|
|||
void vreg_init(void);
|
||||
void ResumeMACASync(void);
|
||||
void radio_init(void);
|
||||
uint32_t init_from_flash(uint32_t addr);
|
||||
void set_power(uint8_t power);
|
||||
void set_channel(uint8_t chan);
|
||||
|
||||
|
|
75
src/maca.c
75
src/maca.c
|
@ -28,7 +28,7 @@ void init_phy(void)
|
|||
maca_framesync = 0x000000A7;
|
||||
maca_clk = 0x00000008;
|
||||
// maca_maskirq = 0; //(maca_irq_cm | maca_irq_acpl | maca_irq_rst | maca_irq_di | maca_irq_crc | maca_irq_flt );
|
||||
maca_maskirq = (maca_irq_rst | maca_irq_acpl | maca_irq_cm | maca_irq_flt);
|
||||
maca_maskirq = (maca_irq_rst | maca_irq_acpl | maca_irq_cm | maca_irq_flt | maca_irq_crc);
|
||||
maca_slotoffset = 0x00350000;
|
||||
}
|
||||
|
||||
|
@ -149,7 +149,7 @@ void vreg_init(void) {
|
|||
|
||||
/* radio_init has been tested to be good */
|
||||
void radio_init(void) {
|
||||
uint32_t i;
|
||||
volatile uint32_t i;
|
||||
/* sequence 1 */
|
||||
for(i=0; i<MAX_SEQ1; i++) {
|
||||
*(volatile uint32_t *)(addr_seq1[i]) = data_seq1[i];
|
||||
|
@ -186,6 +186,24 @@ void radio_init(void) {
|
|||
for(i=0; i<MAX_DATA; i++) {
|
||||
*(volatile uint32_t *)(addr_reg_rep[i]) = data_reg_rep[i];
|
||||
}
|
||||
|
||||
puts("initfromflash\n\r");
|
||||
|
||||
*(volatile uint32_t *)(0x80003048) = 0x00000f04; /* bypass the buck */
|
||||
for(i=0; i<0x161a8; i++) { continue; } /* wait for the bypass to take */
|
||||
// while((((*(volatile uint32_t *)(0x80003018))>>17) & 1) !=1) { continue; } /* wait for the bypass to take */
|
||||
*(volatile uint32_t *)(0x80003048) = 0x00000fa4; /* start the regulators */
|
||||
for(i=0; i<0x161a8; i++) { continue; } /* wait for the bypass to take */
|
||||
|
||||
init_from_flash(0x1F000);
|
||||
|
||||
puts("ram_values:\n\r");
|
||||
for(i=0; i<4; i++) {
|
||||
puts(" 0x");
|
||||
put_hex(ram_values[i]);
|
||||
puts("\n\r");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const uint32_t PSMVAL[19] = {
|
||||
|
@ -354,32 +372,55 @@ void set_channel(uint8_t chan) {
|
|||
#define ENTRY_EOF 0x00000e0f
|
||||
/* processes up to 4 words of initialization entries */
|
||||
/* returns the number of words processed */
|
||||
uint8_t exec_init_entry(uint32_t *entries, uint8_t *valbuf)
|
||||
uint32_t exec_init_entry(uint32_t *entries, uint8_t *valbuf)
|
||||
{
|
||||
volatile uint32_t i;
|
||||
if(entries[0] <= ROM_END) {
|
||||
if (entries[0] == 0) {
|
||||
/* do delay command*/
|
||||
puts("init_entry: delay ");
|
||||
put_hex32(entries[1]);
|
||||
puts("\n\r");
|
||||
for(i=0; i<entries[1]; i++) { continue; }
|
||||
return 2;
|
||||
} else if (entries[0] == 1) {
|
||||
/* do bit set/clear command*/
|
||||
puts("init_entry: bit set clear ");
|
||||
put_hex32(entries[1]);
|
||||
putc(' ');
|
||||
put_hex32(entries[2]);
|
||||
putc(' ');
|
||||
put_hex32(entries[3]);
|
||||
puts("\n\r");
|
||||
reg(entries[2]) = (reg(entries[2]) & ~entries[1]) | (entries[3] & entries[1]);
|
||||
return 4;
|
||||
} else if ((entries[0] >= 16) &&
|
||||
(entries[0] < 0xfff1)) {
|
||||
/* store bytes in valbuf */
|
||||
puts("init_entry: store in valbuf ");
|
||||
put_hex(entries[1]);
|
||||
puts(" position ");
|
||||
put_hex((entries[0]>>4)-1);
|
||||
puts("\n\r");
|
||||
valbuf[(entries[0]>>4)-1] = entries[1];
|
||||
return 2;
|
||||
} else if (entries[0] == ENTRY_EOF) {
|
||||
puts("init_entry: eof ");
|
||||
return 0;
|
||||
} else {
|
||||
/* invalid command code */
|
||||
puts("init_entry: invaild code ");
|
||||
put_hex32(entries[0]);
|
||||
puts("\n\r");
|
||||
return 0;
|
||||
}
|
||||
|
||||
} else { /* address isn't in ROM space */
|
||||
/* do store value in address command */
|
||||
puts("init_entry: address value pair - *0x");
|
||||
put_hex32(entries[0]);
|
||||
puts(" = ");
|
||||
put_hex32(entries[1]);
|
||||
puts("\n\r");
|
||||
reg(entries[0]) = entries[1];
|
||||
return 2;
|
||||
}
|
||||
|
@ -390,18 +431,34 @@ uint8_t exec_init_entry(uint32_t *entries, uint8_t *valbuf)
|
|||
uint32_t init_from_flash(uint32_t addr) {
|
||||
nvmType_t type=0;
|
||||
nvmErr_t err;
|
||||
uint32_t buf[4];
|
||||
uint16_t len;
|
||||
uint32_t i=0;
|
||||
volatile uint32_t buf[8];
|
||||
volatile uint16_t len;
|
||||
volatile uint32_t i=0,j;
|
||||
err = nvm_detect(gNvmInternalInterface_c, &type);
|
||||
puts("nvm_detect returned type ");
|
||||
put_hex32(type);
|
||||
puts(" err ");
|
||||
put_hex(err);
|
||||
puts("\n\r");
|
||||
|
||||
nvm_setsvar(0);
|
||||
err = nvm_read(gNvmInternalInterface_c, type, (uint8_t *)buf, addr, 8);
|
||||
i+=8;
|
||||
puts("nvm_read returned: 0x");
|
||||
put_hex(err);
|
||||
puts("\n\r");
|
||||
|
||||
for(j=0; j<4; j++) {
|
||||
put_hex32(buf[j]);
|
||||
puts("\n\r");
|
||||
}
|
||||
|
||||
if(buf[0] == FLASH_INIT_MAGIC) {
|
||||
len = buf[1] & 0x0000ffff;
|
||||
while(i<len) {
|
||||
while(i<len-4) {
|
||||
volatile uint32_t ret;
|
||||
err = nvm_read(gNvmInternalInterface_c, type, (uint8_t *)buf, addr+i, 32);
|
||||
i += exec_init_entry(buf, ram_values);
|
||||
i += 4*exec_init_entry(buf, ram_values);
|
||||
}
|
||||
return i;
|
||||
} else {
|
||||
|
|
|
@ -31,22 +31,6 @@ void put_hex32(uint32_t x);
|
|||
const uint8_t hex[16]={'0','1','2','3','4','5','6','7',
|
||||
'8','9','a','b','c','d','e','f'};
|
||||
|
||||
void magic(void) {
|
||||
#define X 0x80009a000
|
||||
#define Y 0x80009a008
|
||||
#define VAL 0x0000f7df
|
||||
volatile uint32_t x,y;
|
||||
x = reg(X); /* get X */
|
||||
x &= 0xfffeffff; /* clear bit 16 */
|
||||
reg(X) = x; /* put it back */
|
||||
y = reg(Y); /* get Y */
|
||||
y |= VAL; /* or with the VAL */
|
||||
x = reg(X); /* get X again */
|
||||
x |= 16; /* or with 16 */
|
||||
reg(X) = x; /* put X back */
|
||||
reg(Y) = y; /* put Y back */
|
||||
}
|
||||
|
||||
uint32_t ackBox[10];
|
||||
|
||||
#define MAX_PAYLOAD 128
|
||||
|
@ -221,6 +205,8 @@ void main(void) {
|
|||
|
||||
toggle_led();
|
||||
|
||||
ResumeMACASync();
|
||||
|
||||
command_xcvr_rx();
|
||||
|
||||
break;
|
||||
|
@ -239,72 +225,12 @@ void main(void) {
|
|||
puts("filter failed\n\r");
|
||||
ResumeMACASync();
|
||||
command_xcvr_rx();
|
||||
} else if (_is_checksum_failed_interrupt(maca_irq)) {
|
||||
puts("crc failed\n\r");
|
||||
ResumeMACASync();
|
||||
command_xcvr_rx();
|
||||
}
|
||||
|
||||
/* puts(NL); */
|
||||
|
||||
/* puts("Maca_base"); */
|
||||
/* puts(NL); */
|
||||
/* dump_regs(MACA_BASE,96); */
|
||||
|
||||
/* puts("0x80009000"); */
|
||||
/* puts(NL); */
|
||||
/* dump_regs(0x80009000,192); */
|
||||
|
||||
/* /\* start rx sequence *\/ */
|
||||
/* reg(MACA_CONTROL) = 0x00031a01; /\* abort *\/ */
|
||||
/* while (((tmp = reg(MACA_STATUS)) & 15) == 14) */
|
||||
/* puts("."); */
|
||||
/* puts("abort status is "); put_hex32(tmp); puts(NL); */
|
||||
/* puts("1 status is "); put_hex32(reg(MACA_STATUS)); puts(NL); */
|
||||
/* puts("2 status is "); put_hex32(reg(MACA_STATUS)); puts(NL); */
|
||||
/* puts("3 status is "); put_hex32(reg(MACA_STATUS)); puts(NL); */
|
||||
|
||||
|
||||
/* read TSM_RX_STEPS */
|
||||
|
||||
/* TsmRxSteps = (*((volatile uint32_t *)(0x80009204))); */
|
||||
|
||||
/* puts("TsmRxSteps: "); */
|
||||
/* put_hex32(TsmRxSteps); */
|
||||
/* puts(NL); */
|
||||
|
||||
/* /\* isolate the RX_WU_STEPS *\/ */
|
||||
/* /\* shift left to align with 32-bit addressing *\/ */
|
||||
/* LastWarmupStep = (TsmRxSteps & 0x1f) << 2; */
|
||||
/* /\* Read "current" TSM step and save this value for later *\/ */
|
||||
/* LastWarmupData = (*((volatile uint32_t *)(0x80009300 + LastWarmupStep))); */
|
||||
|
||||
/* puts("LastWarmupData: "); */
|
||||
/* put_hex32(LastWarmupData); */
|
||||
/* puts(NL); */
|
||||
|
||||
/* /\* isolate the RX_WD_STEPS *\/ */
|
||||
/* /\* right-shift bits down to bit 0 position *\/ */
|
||||
/* /\* left-shift to align with 32-bit addressing *\/ */
|
||||
/* LastWarmdownStep = ((TsmRxSteps & 0x1f00) >> 8) << 2; */
|
||||
/* /\* write "last warmdown data" to current TSM step to shutdown rx *\/ */
|
||||
/* LastWarmdownData = (*((volatile uint32_t *)(0x80009300 + LastWarmdownStep))); */
|
||||
|
||||
/* puts("LastWarmdownData: "); */
|
||||
/* put_hex32(LastWarmdownData); */
|
||||
/* puts(NL); */
|
||||
|
||||
/* reg(MACA_CONTROL) = 0x00031a04; /\* receive *\/ */
|
||||
/* while (((tmp = reg(MACA_STATUS)) & 15) == 14) */
|
||||
/* puts("."); */
|
||||
/* puts("complete status is "); put_hex32(tmp); puts(NL); */
|
||||
/* puts("1 status is "); put_hex32(reg(MACA_STATUS)); puts(NL); */
|
||||
/* puts("2 status is "); put_hex32(reg(MACA_STATUS)); puts(NL); */
|
||||
/* puts("3 status is "); put_hex32(reg(MACA_STATUS)); puts(NL); */
|
||||
|
||||
/* puts(NL); */
|
||||
/* for(i=0; i<DELAY; i++) { continue; } */
|
||||
/* for(i=0; i<DELAY; i++) { continue; } */
|
||||
/* for(i=0; i<DELAY; i++) { continue; } */
|
||||
/* for(i=0; i<DELAY; i++) { continue; } */
|
||||
/* for(i=0; i<DELAY; i++) { continue; } */
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
#define reg(x) (*(volatile uint32_t *)(x))
|
||||
|
||||
#define DELAY 400000
|
||||
#define DELAY 100000
|
||||
#define DATA 0x00401000;
|
||||
|
||||
#define NL "\033[K\r\n"
|
||||
|
@ -58,7 +58,7 @@ uint32_t ackBox[10];
|
|||
maca_control = (control_prm | control_asap | control_seq_rx); \
|
||||
}while(FALSE)
|
||||
|
||||
#define PAYLOAD_LEN 16 /* not including the extra 4 bytes for len+fcs+somethingelse */
|
||||
#define PAYLOAD_LEN 8 /* not including the extra 4 bytes for len+fcs+somethingelse */
|
||||
/* maca dmatx needs extra 4 bytes for checksum */
|
||||
/* needs + 4 bytes for len(1 byte) + fcs(2 bytes) + somethingelse */
|
||||
#define command_xcvr_tx() \
|
||||
|
@ -139,10 +139,11 @@ void main(void) {
|
|||
reg(UART1_CON) = 0x00000003; /* enable receive and transmit */
|
||||
reg(GPIO_FUNC_SEL0) = ( (0x01 << (14*2)) | (0x01 << (15*2)) ); /* set GPIO15-14 to UART (UART1 TX and RX)*/
|
||||
|
||||
|
||||
reset_maca();
|
||||
radio_init();
|
||||
flyback_init();
|
||||
vreg_init();
|
||||
flyback_init();
|
||||
init_phy();
|
||||
|
||||
set_power(0x0f); /* 0dbm */
|
||||
|
|
Loading…
Reference in a new issue