Merge remote branch 'libmc1322x/master' into update-libmc1322x
Conflicts: cpu/mc1322x/COPYING
This commit is contained in:
commit
2e331b51e8
9 changed files with 386 additions and 20 deletions
|
@ -102,6 +102,7 @@ enum posts {
|
|||
static volatile uint8_t last_post = NO_POST;
|
||||
|
||||
volatile uint8_t fcs_mode = USE_FCS;
|
||||
volatile uint8_t prm_mode = PROMISC;
|
||||
|
||||
/* call periodically to */
|
||||
/* check that maca_entry is changing */
|
||||
|
@ -181,7 +182,9 @@ void maca_init(void) {
|
|||
|
||||
/* initial radio command */
|
||||
/* nop, promiscuous, no cca */
|
||||
*MACA_CONTROL = (1 << PRM) | (NO_CCA << MODE);
|
||||
*MACA_CONTROL =
|
||||
(prm_mode << PRM) |
|
||||
(NO_CCA << MODE);
|
||||
|
||||
enable_irq(MACA);
|
||||
*INTFRC = (1 << INT_NUM_MACA);
|
||||
|
@ -364,8 +367,8 @@ void post_receive(void) {
|
|||
*MACA_CONTROL = ( (1 << maca_ctrl_asap) |
|
||||
( 4 << PRECOUNT) |
|
||||
( fcs_mode << NOFC ) |
|
||||
( prm_mode << PRM) |
|
||||
(1 << maca_ctrl_auto) |
|
||||
(1 << maca_ctrl_prm) |
|
||||
(maca_ctrl_seq_rx));
|
||||
/* status bit 10 is set immediately */
|
||||
/* then 11, 10, and 9 get set */
|
||||
|
@ -405,7 +408,8 @@ void post_tx(void) {
|
|||
#if PACKET_STATS
|
||||
dma_tx->post_tx++;
|
||||
#endif
|
||||
*MACA_TXLEN = (uint32_t)((dma_tx->length) + 2);
|
||||
*MACA_TXSEQNR = dma_tx->data[2];
|
||||
*MACA_TXLEN = (uint32_t)((dma_tx->length) + 2) | (3 << 16); /* set rx len to ACK length */
|
||||
*MACA_DMATX = (uint32_t)&(dma_tx->data[ 0 + dma_tx->offset]);
|
||||
if(dma_rx == 0) {
|
||||
dma_rx = get_free_packet();
|
||||
|
@ -429,7 +433,8 @@ void post_tx(void) {
|
|||
*MACA_TMREN = (1 << maca_tmren_cpl);
|
||||
|
||||
enable_irq(MACA);
|
||||
*MACA_CONTROL = ( (1 << maca_ctrl_prm) | ( 4 << PRECOUNT) |
|
||||
*MACA_CONTROL = ( ( 4 << PRECOUNT) |
|
||||
( prm_mode << PRM) |
|
||||
(maca_ctrl_mode_no_cca << maca_ctrl_mode) |
|
||||
(1 << maca_ctrl_asap) |
|
||||
(maca_ctrl_seq_tx));
|
||||
|
@ -537,21 +542,21 @@ void decode_status(void) {
|
|||
{
|
||||
case ABORTED:
|
||||
{
|
||||
// PRINTF("maca: aborted\n\r");
|
||||
PRINTF("maca: aborted\n\r");
|
||||
ResumeMACASync();
|
||||
break;
|
||||
|
||||
}
|
||||
case NOT_COMPLETED:
|
||||
{
|
||||
// PRINTF("maca: not completed\n\r");
|
||||
PRINTF("maca: not completed\n\r");
|
||||
ResumeMACASync();
|
||||
break;
|
||||
|
||||
}
|
||||
case CODE_TIMEOUT:
|
||||
{
|
||||
// PRINTF("maca: timeout\n\r");
|
||||
PRINTF("maca: timeout\n\r");
|
||||
ResumeMACASync();
|
||||
break;
|
||||
|
||||
|
@ -565,7 +570,7 @@ void decode_status(void) {
|
|||
}
|
||||
case EXT_TIMEOUT:
|
||||
{
|
||||
// PRINTF("maca: ext timeout\n\r");
|
||||
PRINTF("maca: ext timeout\n\r");
|
||||
ResumeMACASync();
|
||||
break;
|
||||
|
||||
|
@ -584,7 +589,7 @@ void decode_status(void) {
|
|||
}
|
||||
default:
|
||||
{
|
||||
PRINTF("status: %x", *MACA_STATUS);
|
||||
PRINTF("status: %x", (unsigned int)*MACA_STATUS);
|
||||
ResumeMACASync();
|
||||
|
||||
}
|
||||
|
@ -610,8 +615,17 @@ void maca_isr(void) {
|
|||
*MACA_CLRIRQ = (1 << maca_irq_di);
|
||||
dma_rx->length = *MACA_GETRXLVL - 2; /* packet length does not include FCS */
|
||||
dma_rx->lqi = get_lqi();
|
||||
// PRINTF("maca data ind %x %d\n\r", dma_rx, dma_rx->length);
|
||||
|
||||
/* check if received packet needs an ack */
|
||||
if(dma_rx->data[1] & 0x20) {
|
||||
/* this wait is necessary to auto-ack */
|
||||
volatile uint32_t wait_clk;
|
||||
wait_clk = *MACA_CLK + 200;
|
||||
while(*MACA_CLK < wait_clk) { continue; }
|
||||
}
|
||||
|
||||
if(maca_rx_callback != 0) { maca_rx_callback(dma_rx); }
|
||||
|
||||
add_to_rx(dma_rx);
|
||||
dma_rx = 0;
|
||||
}
|
||||
|
@ -634,6 +648,7 @@ void maca_isr(void) {
|
|||
if(action_complete_irq()) {
|
||||
/* PRINTF("maca action complete %d\n\r", get_field(*MACA_CONTROL,SEQUENCE)); */
|
||||
if(last_post == TX_POST) {
|
||||
tx_head->status = get_field(*MACA_STATUS,CODE);
|
||||
if(maca_tx_callback != 0) { maca_tx_callback(tx_head); }
|
||||
dma_tx = 0;
|
||||
free_tx_head();
|
||||
|
@ -646,7 +661,7 @@ void maca_isr(void) {
|
|||
decode_status();
|
||||
|
||||
if (*MACA_IRQ != 0)
|
||||
{ PRINTF("*MACA_IRQ %x\n\r", *MACA_IRQ); }
|
||||
{ PRINTF("*MACA_IRQ %x\n\r", (unsigned int)*MACA_IRQ); }
|
||||
|
||||
if(tx_head != 0) {
|
||||
post_tx();
|
||||
|
@ -669,6 +684,9 @@ void init_phy(void)
|
|||
*MACA_TXCCADELAY = 0x00000025;
|
||||
*MACA_FRAMESYNC0 = 0x000000A7;
|
||||
*MACA_CLK = 0x00000008;
|
||||
*MACA_RXACKDELAY = 30;
|
||||
*MACA_RXEND = 180;
|
||||
*MACA_TXACKDELAY = 68;
|
||||
*MACA_MASKIRQ = ((1 << maca_irq_rst) |
|
||||
(1 << maca_irq_acpl) |
|
||||
(1 << maca_irq_cm) |
|
||||
|
@ -902,7 +920,7 @@ void radio_init(void) {
|
|||
PRINTF("radio_init: ctov parameter 0x%02x\n\r",ram_values[3]);
|
||||
for(i=0; i<16; i++) {
|
||||
ctov[i] = get_ctov(i,ram_values[3]);
|
||||
PRINTF("radio_init: ctov[%d] = 0x%02x\n\r",i,ctov[i]);
|
||||
PRINTF("radio_init: ctov[%d] = 0x%02x\n\r",(int)i,ctov[i]);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1091,18 +1109,20 @@ uint32_t exec_init_entry(volatile uint32_t *entries, uint8_t *valbuf)
|
|||
if(entries[0] <= ROM_END) {
|
||||
if (entries[0] == 0) {
|
||||
/* do delay command*/
|
||||
PRINTF("init_entry: delay 0x%08x\n\r", entries[1]);
|
||||
PRINTF("init_entry: delay 0x%08x\n\r", (unsigned int)entries[1]);
|
||||
for(i=0; i<entries[1]; i++) { continue; }
|
||||
return 2;
|
||||
} else if (entries[0] == 1) {
|
||||
/* do bit set/clear command*/
|
||||
PRINTF("init_entry: bit set clear 0x%08x 0x%08x 0x%08x\n\r", entries[1], entries[2], entries[3]);
|
||||
PRINTF("init_entry: bit set clear 0x%08x 0x%08x 0x%08x\n\r", (unsigned int)entries[1], (unsigned int)entries[2], (unsigned int)entries[3]);
|
||||
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 */
|
||||
PRINTF("init_entry: store in valbuf 0x%02x position %d\n\r", entries[1],(entries[0]>>4)-1);
|
||||
PRINTF("init_entry: store in valbuf 0x%02x position %d\n\r",
|
||||
(unsigned int)entries[1],
|
||||
(unsigned int)(entries[0]>>4)-1);
|
||||
valbuf[(entries[0]>>4)-1] = entries[1];
|
||||
return 2;
|
||||
} else if (entries[0] == ENTRY_EOF) {
|
||||
|
@ -1110,12 +1130,14 @@ uint32_t exec_init_entry(volatile uint32_t *entries, uint8_t *valbuf)
|
|||
return 0;
|
||||
} else {
|
||||
/* invalid command code */
|
||||
PRINTF("init_entry: invaild code 0x%08x\n\r",entries[0]);
|
||||
PRINTF("init_entry: invaild code 0x%08x\n\r",(unsigned int)entries[0]);
|
||||
return 0;
|
||||
}
|
||||
} else { /* address isn't in ROM space */
|
||||
/* do store value in address command */
|
||||
PRINTF("init_entry: address value pair - *0x%08x = 0x%08x\n\r",entries[0],entries[1]);
|
||||
PRINTF("init_entry: address value pair - *0x%08x = 0x%08x\n\r",
|
||||
(unsigned int)entries[0],
|
||||
(unsigned int)entries[1]);
|
||||
reg(entries[0]) = entries[1];
|
||||
return 2;
|
||||
}
|
||||
|
@ -1139,7 +1161,7 @@ uint32_t init_from_flash(uint32_t addr) {
|
|||
PRINTF("nvm_read returned: 0x%02x\n\r",err);
|
||||
|
||||
for(j=0; j<4; j++) {
|
||||
PRINTF("0x%08x\n\r",buf[j]);
|
||||
PRINTF("0x%08x\n\r",(unsigned int)buf[j]);
|
||||
}
|
||||
|
||||
if(buf[0] == FLASH_INIT_MAGIC) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue