Changeset 581

Show
Ignore:
Timestamp:
05/12/08 19:59:11 (2 months ago)
Author:
apurohit
Message:

Phoenix programmer with PING/ Console MAC input

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • nano-RK/projects/SAMPL/phoenix-reprogrammer/main.c

    r571 r581  
    3939#define REPLY_WAIT_NANOSECS 400 * NANOS_PER_MS 
    4040 
     41#define PING_WAIT_SECS  3 
     42 
    4143#define my_subnet_mac   0        
    42 #define my_mac          1 
    43 #define dest_subnet_mac 0 
    44 #define dest_mac        4 
     44#define my_mac  0 
     45 
    4546 
    4647#define TXT_DEBUG 
     
    6263#define ABORT_MSG       'A' 
    6364#define SUCCESS_MSG     'S' 
     65 
     66// Program states 
     67#define PING    0 
     68#define UPDATE  1 
     69#define NONE    2 
    6470 
    6571// PKT_TYPE defined in ../include/SAMPL.h 
     
    8187int8_t rssi, val; 
    8288uint8_t *local_rx_buf; 
     89uint8_t charCount; 
     90nrk_time_t start, current; 
     91 
     92uint8_t programState; 
     93 
     94// Setup uart 
     95char c; 
     96nrk_sig_t uart_rx_signal; 
     97nrk_sig_mask_t sm; 
     98 
     99 
     100// tx task signals 
     101nrk_sig_t tx_done_signal; 
     102nrk_sig_t rx_signal; 
     103nrk_time_t check_period; 
     104nrk_time_t timeout; 
     105nrk_sig_mask_t my_sigs; 
     106 
     107// Mac addr vars 
     108char mac_addr[8]; 
     109char buffer0[3]; 
     110char buffer1[3]; 
     111char buffer2[3]; 
     112char buffer3[3]; 
     113 
     114uint8_t dest_mac[4]; 
    83115 
    84116// Global state for TX protocol 
     
    88120uint8_t pgNumber; 
    89121uint8_t needReply; 
     122 
    90123// Buffer for flash pages 
    91124uint8_t ph_buf[PAGESIZE]; 
     
    95128void buildTxPkt (void); 
    96129void changeState (void); 
    97 inline void initStatus(); 
     130void initStatus(); 
     131void startStatus(); 
     132void pingReplyRecieved(); 
     133void updateReplyRecieved(); 
     134void updateMode(); 
     135void pingMode(); 
     136void getDestMac(); 
     137void phoenix_init(); 
    98138//***************************************************** 
    99139 
     
    115155int main () 
    116156{ 
     157 
     158  // init phoenix 
     159  phoenix_init(); 
    117160   
     161  nrk_setup_ports (); 
     162  nrk_setup_uart (UART_BAUDRATE_115K2); 
     163 
     164  nrk_init (); 
     165 
     166  nrk_led_clr (0); 
     167  nrk_led_clr (1); 
     168  nrk_led_clr (2); 
     169  nrk_led_clr (3); 
     170 
     171  nrk_time_set (0, 0); 
     172 
     173  bmac_task_config (); 
     174 
     175  nrk_create_taskset (); 
     176  nrk_start (); 
     177 
     178  return 0; 
     179} 
     180 
     181void tx_task () 
     182{ 
     183  // Get the signal for UART RX 
     184  //uart_rx_signal=nrk_uart_rx_signal_get(); 
     185  // Register your task to wakeup on RX Data  
     186  //if(uart_rx_signal==NRK_ERROR) nrk_kprintf( PSTR("Get Signal ERROR!\r\n") ); 
     187  //nrk_signal_register(uart_rx_signal); 
     188 
     189  //printf ("tx_task PID=%d\r\n", nrk_get_pid ()); 
     190 
     191  // Wait until the tx_task starts up bmac 
     192  // This should be called by all tasks using bmac that 
     193  // do not call bmac_init()... 
     194  bmac_init (26); 
     195 
     196  bmac_encryption_set_key(aes_key,16); 
     197  bmac_encryption_enable(); 
     198 
     199  bmac_rx_pkt_set_buffer (rx_buf, RF_MAX_PAYLOAD_SIZE); 
     200 
     201  //nrk_kprintf (PSTR ("bmac_started()\r\n")); 
     202  bmac_set_cca_thresh (-45); 
     203 
     204  check_period.secs = 0; 
     205  check_period.nano_secs = 100 * NANOS_PER_MS; 
     206  val = bmac_set_rx_check_rate (check_period); 
     207 
     208  // Get and register the tx_done_signal if you want to 
     209  // do non-blocking transmits 
     210  tx_done_signal = bmac_get_tx_done_signal (); 
     211  nrk_signal_register (tx_done_signal); 
     212 
     213  rx_signal = bmac_get_rx_pkt_signal (); 
     214  nrk_signal_register (rx_signal); 
     215 
     216  cnt = 0; 
     217 
     218  while (1) 
     219  { 
     220      nrk_kprintf(PSTR("\r\n*************************************************************\r\n")); 
     221      nrk_kprintf(PSTR("               PHOENIX WIRELESS UPDATE SYSTEM                \r\n")); 
     222      nrk_kprintf(PSTR("*************************************************************\r\n")); 
     223      nrk_kprintf(PSTR("Press 'p' : To PING Nodes in Vicinity                        \r\n")); 
     224      nrk_kprintf(PSTR("Press 'u' : To Begin Node Update                             \r\n")); 
     225      nrk_kprintf(PSTR("                                                             \r\n")); 
     226      nrk_kprintf(PSTR("*************************************************************\r\n")); 
     227 
     228      printf("Enter Choice: "); 
     229       
     230      //sm=nrk_event_wait(SIG(uart_rx_signal)); 
     231     
     232      //if(sm != SIG(uart_rx_signal)) 
     233      //{ 
     234      //  nrk_kprintf( PSTR("UART signal error\r\n") ); 
     235      //  while(1); 
     236      //} 
     237      // Wait for UART signal 
     238      while(1) 
     239      { 
     240        if(nrk_uart_data_ready(NRK_DEFAULT_UART)!=0) 
     241        { 
     242          // Read Character 
     243          c=getchar(); 
     244          printf( "%c\r\n",c); 
     245          break; 
     246        } 
     247        timeout.secs = 0; 
     248        timeout.nano_secs = 20 * NANOS_PER_MS; 
     249        nrk_wait(timeout); 
     250      } 
     251      // Choose mode 
     252      switch(c){ 
     253        case 'p': 
     254          programState = PING; 
     255          break; 
     256        case 'u': 
     257          getDestMac(); 
     258          phoenix_init(); 
     259          programState = UPDATE; 
     260          break; 
     261        default: 
     262          programState = NONE; 
     263          nrk_kprintf(PSTR("Invalid Command! Please Try Again\r\n")); 
     264      } 
     265 
     266      // Reset c 
     267      c = 0; 
     268 
     269      nrk_wait_until_next_period(); 
     270 
     271      // Execute protocol 
     272      switch(programState) 
     273      { 
     274        case PING: 
     275          pingMode(); 
     276          break; 
     277        case UPDATE: 
     278          updateMode(); 
     279          break; 
     280        case NONE:;// Do nothing 
     281          break; 
     282        default: 
     283          nrk_kprintf(PSTR("Invalid Program State\r\n")); 
     284          break; 
     285      } 
     286      nrk_wait_until_next_period (); 
     287  } 
     288} 
     289 
     290void phoenix_init() 
     291{ 
    118292  //*************************************** 
    119293  // Init Phoenix variables 
     294  programState = PING; 
    120295  txState = START; 
    121296  // Initialize tx status 
     
    124299  needReply = FALSE; 
    125300 
     301  charCount = 0; 
    126302  //*************************************** 
    127  
    128   nrk_setup_ports (); 
    129   nrk_setup_uart (UART_BAUDRATE_115K2); 
    130  
    131   nrk_init (); 
    132  
    133   nrk_led_clr (0); 
    134   nrk_led_clr (1); 
    135   nrk_led_clr (2); 
    136   nrk_led_clr (3); 
    137  
    138   nrk_time_set (0, 0); 
    139  
    140   bmac_task_config (); 
    141  
    142   nrk_create_taskset (); 
    143   nrk_start (); 
    144  
    145   return 0; 
    146 
    147  
    148 void tx_task () 
    149 
    150   nrk_sig_t tx_done_signal; 
    151   nrk_sig_t rx_signal; 
    152   nrk_time_t check_period; 
    153   nrk_time_t timeout; 
    154   nrk_sig_mask_t my_sigs; 
    155  
    156   printf ("tx_task PID=%d\r\n", nrk_get_pid ()); 
    157  
    158  
    159   // Wait until the tx_task starts up bmac 
    160   // This should be called by all tasks using bmac that 
    161   // do not call bmac_init()... 
    162   bmac_init (26); 
    163  
    164   bmac_encryption_set_key(aes_key,16); 
    165   bmac_encryption_enable(); 
    166  
    167   bmac_rx_pkt_set_buffer (rx_buf, RF_MAX_PAYLOAD_SIZE); 
    168  
     303
     304 
     305//*************************PING MODE************************************************ 
     306void getDestMac() 
     307
     308 
     309  mac_addr[0] = '\0'; 
     310   
     311  nrk_kprintf(PSTR("\r\n*************************************************************\r\n")); 
     312  nrk_kprintf(PSTR("         Please Enter Address of Node to Program             \r\n")); 
     313  nrk_kprintf(PSTR("     MAC (Subnet + Dest) 4 Bytes Hex E.g. 00000004           \r\n")); 
     314  nrk_kprintf(PSTR("*************************************************************\r\n")); 
     315  printf("Enter MAC:"); 
     316 
     317  charCount = 0; 
     318 
     319  // Enter Mac 
     320  do 
     321  { 
     322    // Wait for UART signal 
     323    while(1) 
     324    { 
     325      if(nrk_uart_data_ready(NRK_DEFAULT_UART)!=0) 
     326      { 
     327        while(nrk_uart_data_ready(NRK_DEFAULT_UART)!=0) 
     328        { 
     329          charCount++; 
     330          // Read Character 
     331          c=getchar(); 
     332          printf( "%c",c); 
     333          sprintf(mac_addr,"%s%c",mac_addr,c); 
     334        } 
     335        break; 
     336      } 
     337      timeout.secs = 0; 
     338      timeout.nano_secs = 20 * NANOS_PER_MS; 
     339      nrk_wait(timeout); 
     340    } 
     341  }while(charCount < 8); 
     342 
     343   
     344  buffer0[0]=mac_addr[0]; buffer0[1]=mac_addr[1]; buffer0[3]='\0'; 
     345  buffer1[0]=mac_addr[2]; buffer1[1]=mac_addr[3]; buffer1[3]='\0'; 
     346  buffer2[0]=mac_addr[4]; buffer2[1]=mac_addr[5]; buffer2[3]='\0'; 
     347  buffer3[0]=mac_addr[6]; buffer3[1]=mac_addr[7]; buffer3[3]='\0'; 
     348  val=sscanf( buffer0,"%x",&dest_mac[3]); 
     349  val+=sscanf( buffer1,"%x",&dest_mac[2]); 
     350  val+=sscanf( buffer2,"%x",&dest_mac[1]); 
     351  val+=sscanf( buffer3,"%x",&dest_mac[0]); 
     352 
     353 
     354  nrk_kprintf(PSTR("\r\n*************************************************************\r\n")); 
     355  nrk_kprintf(PSTR("                       Node MAC Accepted                     \r\n")); 
     356            printf("       Initiating Update for Node 0 x %X %X %X %X        \r\n", dest_mac[3],dest_mac[2],dest_mac[1], dest_mac[0]); 
     357  nrk_kprintf(PSTR("*************************************************************\r\n")); 
     358 
     359
     360 
     361 
     362void pingMode() 
     363
     364 
     365  // Broadcast for ping 
    169366  val=bmac_addr_decode_set_my_mac(((uint16_t)my_subnet_mac<<8)|my_mac); 
    170   val=bmac_addr_decode_dest_mac(((uint16_t)dest_subnet_mac<<8)|dest_mac);  // broadcast by default 
     367  val=bmac_addr_decode_dest_mac((uint16_t)0xffff);  // broadcast by default 
    171368  bmac_addr_decode_enable(); 
    172  
    173   nrk_kprintf (PSTR ("bmac_started()\r\n")); 
    174   bmac_set_cca_thresh (-45); 
     369   
     370  uint8_t i; 
     371   
     372  // Build a TX packet by hand... 
     373  p2p_pkt.pkt_type = PING_PKT; 
     374    // set as p2p packet (no US_MASK or DS_MASK) 
     375  p2p_pkt.ctrl_flags = MOBILE_MASK; // | DEBUG_FLAG ; 
     376  p2p_pkt.ack_retry= 0x00; 
     377  p2p_pkt.ttl = 1; 
     378  p2p_pkt.subnet_mac[0] = 1; 
     379  p2p_pkt.subnet_mac[1] = 2; 
     380  p2p_pkt.subnet_mac[2] = 3; 
     381  p2p_pkt.src_mac = my_mac; 
     382  p2p_pkt.last_hop_mac = my_mac; 
     383  p2p_pkt.dst_mac = BROADCAST; 
     384  p2p_pkt.buf=tx_buf; 
     385  p2p_pkt.buf_len = P2P_PAYLOAD_START; 
     386  p2p_pkt.seq_num = cnt; 
     387  p2p_pkt.priority = 0; 
     388 
     389//    p2p_pkt.payload[0]=my_mac; 
     390//    p2p_pkt.payload_len=1; 
     391//    ping_p2p_generate(&p2p_pkt); 
     392 
     393  nrk_led_set (BLUE_LED); 
    175394 
    176395  check_period.secs = 0; 
     
    178397  val = bmac_set_rx_check_rate (check_period); 
    179398 
    180   // Get and register the tx_done_signal if you want to 
    181   // do non-blocking transmits 
    182   tx_done_signal = bmac_get_tx_done_signal (); 
    183   nrk_signal_register (tx_done_signal); 
    184  
    185   rx_signal = bmac_get_rx_pkt_signal (); 
    186   nrk_signal_register (rx_signal); 
    187  
    188   cnt = 0; 
    189  
    190   while (1) 
     399    // Pack data structure values in buffer before transmit 
     400  pack_peer_2_peer_packet(&p2p_pkt); 
     401    // For blocking transmits, use the following function call. 
     402  val = bmac_tx_pkt (p2p_pkt.buf, p2p_pkt.buf_len); 
     403 
     404  check_period.secs = 0; 
     405  check_period.nano_secs = FAST_CHECK_RATE * NANOS_PER_MS; 
     406  val = bmac_set_rx_check_rate (check_period); 
     407#ifdef TXT_DEBUG 
     408  nrk_kprintf (PSTR ("\r\nPING Packet Sent. Waiting for Replies...\r\n\n")); 
     409#endif 
     410  nrk_led_clr (BLUE_LED); 
     411  nrk_led_clr(GREEN_LED); 
     412 
     413    // Wait for packets or timeout 
     414  nrk_time_get (&start); 
     415     
     416  while (1) { 
     417 
     418    timeout.secs = PING_WAIT_SECS; 
     419    timeout.nano_secs = 0; 
     420 
     421      // Wait until an RX packet is received 
     422      //val = bmac_wait_until_rx_pkt (); 
     423    nrk_set_next_wakeup (timeout); 
     424    my_sigs = nrk_event_wait (SIG (rx_signal) | SIG (nrk_wakeup_signal)); 
     425 
     426 
     427    if (my_sigs == 0) 
     428      nrk_kprintf (PSTR ("Error calling nrk_event_wait()\r\n")); 
     429    if (my_sigs & SIG (rx_signal)) {     
     430        // Get the RX packet  
     431      local_rx_buf = bmac_rx_pkt_get (&len, &rssi); 
     432        // Check the packet type from raw buffer before unpacking 
     433      if ((local_rx_buf[CTRL_FLAGS] & (DS_MASK | US_MASK)) == 0) { 
     434        // Set the buffer 
     435        p2p_pkt.buf=local_rx_buf; 
     436        p2p_pkt.buf_len=len; 
     437        p2p_pkt.rssi=rssi; 
     438        unpack_peer_2_peer_packet(&p2p_pkt); 
     439        if (p2p_pkt.dst_mac == my_mac || p2p_pkt.dst_mac == BROADCAST) { 
     440          nrk_led_set(GREEN_LED); 
     441          // Packet arrived and is good to go 
     442          printf( "Mac: %x%x%x",p2p_pkt.subnet_mac[0], p2p_pkt.subnet_mac[1], p2p_pkt.subnet_mac[2]); 
     443          printf( "%x ",p2p_pkt.src_mac); 
     444          printf( "| RSSI: %d ",p2p_pkt.rssi); 
     445          printf( "| Type: %d \r\n",p2p_pkt.pkt_type); 
     446        } 
     447      } 
     448      // Release the RX buffer so future packets can arrive 
     449      bmac_rx_pkt_release (); 
     450    } 
     451    nrk_time_get (&current); 
     452    if (start.secs + PING_WAIT_SECS < current.secs) 
     453      break; 
     454  } 
     455  nrk_kprintf (PSTR ("\r\nDone Waiting for Response...\r\n")); 
     456  nrk_led_clr(GREEN_LED); 
     457
     458 
     459//**************************UPDATE MODE*********************************************************** 
     460 
     461// Run update Mode Protocol 
     462void updateMode() 
     463
     464  // Set destination 
     465  val=bmac_addr_decode_set_my_mac(((uint16_t)my_subnet_mac<<8)|my_mac); 
     466  val=bmac_addr_decode_dest_mac(((uint16_t)dest_mac[1]<<8)|dest_mac[0]); 
     467  bmac_addr_decode_enable(); 
     468   
     469  while(programState == UPDATE) 
    191470  { 
    192471    // Build tx packet by txState 
    193472    buildTxPkt(); 
    194  
     473     
    195474    nrk_led_toggle (BLUE_LED); 
     475 
     476    check_period.secs = 0; 
     477    check_period.nano_secs = 100 * NANOS_PER_MS; 
     478    val = bmac_set_rx_check_rate (check_period); 
    196479 
    197480    // Send with hardware acknowledgement. 
     
    211494    } 
    212495 
    213     #ifdef TXT_DEBUG 
     496  #ifdef TXT_DEBUG 
    214497      nrk_kprintf (PSTR ("\r\nSent Request:\r\n")); 
    215     #endif 
     498  #endif 
    216499    nrk_led_clr (BLUE_LED); 
    217500    nrk_led_clr(GREEN_LED); 
    218501 
    219     // Wait if reply expected / Change TX state if not 
    220     //*********************************************************** 
     502      // Wait if reply expected / Change TX state if not 
     503      //*********************************************************** 
    221504    if(needReply == FALSE) 
    222505    { 
    223       // Change TX state, update page number 
     506        // Change TX state, update page number 
    224507      changeState(); 
    225508    } 
    226509    else 
    227510    { 
    228       // Wait for packets or timeout 
    229         #ifdef TXT_DEBUG 
    230           nrk_kprintf (PSTR ("\r\nExpecting Reply\r\n")); 
    231         #endif 
    232            
    233         timeout.secs = REPLY_WAIT_SECS; 
    234         timeout.nano_secs = REPLY_WAIT_NANOSECS; 
    235  
    236         nrk_set_next_wakeup (timeout); 
    237         //bmac_wait_until_rx_pkt (); 
    238         my_sigs = nrk_event_wait (SIG (rx_signal) | SIG (nrk_wakeup_signal)); 
    239  
    240         if (my_sigs == 0) 
    241           nrk_kprintf (PSTR ("Error calling nrk_event_wait()\r\n")); 
    242         if (my_sigs & SIG (rx_signal)) { 
     511        // Wait for packets or timeout 
     512  #ifdef TXT_DEBUG 
     513        nrk_kprintf (PSTR ("\r\nExpecting Reply\r\n")); 
     514  #endif 
     515      timeout.secs = REPLY_WAIT_SECS; 
     516      timeout.nano_secs = REPLY_WAIT_NANOSECS; 
     517 
     518      nrk_set_next_wakeup (timeout); 
     519      my_sigs = nrk_event_wait (SIG (rx_signal) | SIG (nrk_wakeup_signal)); 
     520 
     521      if (my_sigs == 0) 
     522        nrk_kprintf (PSTR ("Error calling nrk_event_wait()\r\n")); 
     523      if (my_sigs & SIG (rx_signal)) 
     524      { 
    243525            // Get the RX packet 
    244             local_rx_buf = bmac_rx_pkt_get (&len, &rssi); 
    245             nrk_led_clr (ORANGE_LED); 
    246             #ifdef TXT_DEBUG 
    247               nrk_kprintf (PSTR ("Recieved Reply\r\n")); 
    248             #endif 
    249             // Check if INIT Success 
    250             // Release the RX buffer inside 
    251             if (txState == INIT){ 
    252               initStatus(); 
    253             } 
    254             else if (txState == START){ 
    255               initStatus(); 
    256             } 
    257             else 
    258               bmac_rx_pkt_release (); 
    259         } 
    260         else { 
    261             #ifdef TXT_DEBUG 
    262             nrk_kprintf (PSTR ("Timed Out Waiting for response...\r\n")); 
    263             #endif 
    264         } 
    265     }  
    266     //*********************************************************** 
    267     nrk_wait_until_next_period (); 
    268   } 
    269 
     526        local_rx_buf = bmac_rx_pkt_get (&len, &rssi); 
     527        nrk_led_clr (ORANGE_LED); 
     528  #ifdef TXT_DEBUG 
     529        nrk_kprintf (PSTR ("Recieved Reply\r\n")); 
     530  #endif 
     531        // Handle recieved packet 
     532        updateReplyRecieved(); 
     533      } 
     534      else 
     535      { 
     536  #ifdef TXT_DEBUG 
     537        nrk_kprintf (PSTR ("Timed Out Waiting for response...\r\n")); 
     538  #endif 
     539      } 
     540    } 
     541    nrk_wait_until_next_period(); 
     542  } 
     543
     544 
     545 
     546// Update Protocol reply recieved 
     547void updateReplyRecieved() 
     548
     549  // Check if INIT Success 
     550  // Release the RX buffer inside 
     551  if (txState == INIT){ 
     552    initStatus(); 
     553  } 
     554  else if (txState == START){ 
     555    startStatus(); 
     556  } 
     557  else 
     558    bmac_rx_pkt_release (); 
     559
     560 
    270561 
    271562// Check if init succeeded 
    272 inline void initStatus() 
     563void initStatus() 
    273564{ 
    274565  if((local_rx_buf[PKT_TYPE] == UNKNOWN_PKT) && 
     
    285576    bmac_rx_pkt_release (); 
    286577    nrk_kprintf (PSTR ("Update Checksum Failed\r\n")); 
     578    programState = PING; 
     579  } 
     580} 
     581 
     582// Check if start succeeded 
     583void startStatus() 
     584{ 
     585  if((local_rx_buf[PKT_TYPE] == UNKNOWN_PKT) && 
     586      (local_rx_buf[MSG_TYPE] == SUCCESS_MSG)) 
     587  { 
     588    // Release the RX buffer so future packets can arrive 
     589    bmac_rx_pkt_release (); 
     590   // Change TX state, update page number 
     591    changeState(); 
     592  } 
     593  else 
     594  { 
     595    bmac_rx_pkt_release (); 
    287596  } 
    288597} 
     
    303612        // Build a TX packet by hand... 
    304613        p2p_pkt.pkt_type = WIRELESS_UPDATE_PKT; 
    305         p2p_pkt.ctrl_flags = MOBILE_MASK;  // set as p2p packet (no US_MASK or DS_MASK) 
     614        p2p_pkt.ctrl_flags = ENCRYPT;  // set as p2p packet (no US_MASK or DS_MASK) 
    306615        p2p_pkt.ack_retry= 0x00; 
    307616        p2p_pkt.ttl = 1; 
    308617        p2p_pkt.check_rate = DEFAULT_CHECK_RATE; 
    309        // FIXME: add proper subnet later 
    310         p2p_pkt.subnet_mac[0] = dest_subnet_mac
    311         p2p_pkt.subnet_mac[1] = dest_subnet_mac
    312         p2p_pkt.subnet_mac[2] = dest_subnet_mac
     618        // FIXME: add proper subnet later 
     619        p2p_pkt.subnet_mac[0] = dest_mac[1]
     620        p2p_pkt.subnet_mac[1] = dest_mac[2]
     621        p2p_pkt.subnet_mac[2] = dest_mac[3]
    313622        p2p_pkt.src_mac = my_mac; 
    314623        p2p_pkt.last_hop_mac = my_mac; 
    315         p2p_pkt.dst_mac = dest_mac
     624        p2p_pkt.dst_mac = dest_mac[0]
    316625        p2p_pkt.buf=tx_buf; 
    317626        p2p_pkt.buf_len = P2P_PAYLOAD_START; 
    318627        p2p_pkt.seq_num = cnt; 
    319628        p2p_pkt.priority = 0; 
    320         //    p2p_pkt.payload[0]=my_mac; 
    321         //    p2p_pkt.payload_len=1; 
    322         //    ping_p2p_generate(&p2p_pkt); 
     629        // p2p_pkt.payload[0]=my_mac; 
     630        // p2p_pkt.payload_len=1; 
     631        // ping_p2p_generate(&p2p_pkt); 
    323632        needReply = TRUE; 
    324633 
     
    330639        for(i=0;i<len;i++) 
    331640          tx_buf[i] = p2p_pkt.buf[i]; 
    332          
    333641        break; 
    334642       
     
    345653        tx_buf[UP_CSUM]  = UpdateChecksum; 
    346654        len = CMD_PAYLOAD; 
    347        // Need a checksum success reply 
     655        // Need a checksum success reply 
    348656        needReply = TRUE; 
    349657        break; 
     
    446754            nrk_kprintf (PSTR ("\r\nState STOP\r\n")); 
    447755          #endif 
     756          // Update complete go to ping mode again 
     757          programState = PING; 
    448758          break; 
    449759    default: 
     
    454764} 
    455765 
    456  
     766//**************************UPDATE MODE ENDS*********************************************************** 
    457767 
    458768void nrk_create_taskset () 
  • nano-RK/projects/SAMPL/phoenix-reprogrammer/nrk_cfg.h

    r365 r581  
    2727 
    2828// Enable buffered and signal controlled serial RX 
    29 #define NRK_UART_BUF   1 
     29#define NRK_UART_BUF   0 
    3030 
    3131// Set buffer to MAX slip packet size 
     
    3737// Making this the correct size will save on BSS memory which 
    3838// is both RAM and ROM... 
    39 #define NRK_MAX_TASKS                  4    
     39#define NRK_MAX_TASKS         3 
    4040                            
    4141#define NRK_TASK_IDLE_STK_SIZE         128 // Idle task stack size min=32