Beispiel #1
0
/** Write local mailbox buffer ESCvar.MBX[n] to Send mailbox.
 * Combined function for bootstrap and other states. State check decides
 * which one to write.
 *
 * @param[in] n   = Which local mailbox buffer n to send.
 */
void ESC_writembx (uint8_t n)
{
   _MBX *MB = &MBX[n];
   uint8_t dummy = 0;
   uint16_t length;
   length = etohs (MB->header.length);
   if (ESCvar.ALstatus == ESCboot)
   {
      if (length > (MBX1_sml_b - MBXHSIZE))
      {
         length = MBX1_sml_b - MBXHSIZE;
      }
      ESC_write (MBX1_sma_b, MB, MBXHSIZE + length, (void *) &ESCvar.ALevent);
      if (length + MBXHSIZE < MBX1_sml_b)
      {
         ESC_write (MBX1_sme_b, &dummy, 1, (void *) &ESCvar.ALevent);
      }
   }
   else
   {
      if (length > (MBX1_sml - MBXHSIZE))
      {
         length = MBX1_sml - MBXHSIZE;
      }
      ESC_write (MBX1_sma, MB, MBXHSIZE + length, (void *) &ESCvar.ALevent);
      if (length + MBXHSIZE < MBX1_sml)
      {
         ESC_write (MBX1_sme, &dummy, 1, (void *) &ESCvar.ALevent);
      }
   }
   ESCvar.mbxfree = 0;
}
Beispiel #2
0
/** EPP periodic task of ESC side EEPROM emulation.
 *
 */
void EEP_process (void)
{
   eep_stat_t stat;

   /* check for eeprom event */
   if ((ESCvar.ALevent & ESCREG_ALEVENT_EEP) == 0) {
     return;
   }

   while (1) {
      /* read eeprom status */
      ESC_read (ESCREG_EECONTSTAT, &stat, sizeof (eep_stat_t));
      stat.contstat.reg = etohs(stat.contstat.reg);
      stat.addr = etohl(stat.addr);

      /* check busy flag, exit if job finished */
      if (!stat.contstat.bits.busy) {
        return;
      }

      /* clear error bits */
      stat.contstat.bits.csumErr = 0;
      stat.contstat.bits.eeLoading = 0;
      stat.contstat.bits.ackErr = 0;
      stat.contstat.bits.wrErr = 0;

      /* process commands */
      switch (stat.contstat.bits.cmdReg) {
         case EEP_CMD_IDLE:
            break;

         case EEP_CMD_READ:
         case EEP_CMD_RELOAD:
            /* handle read request */
            if (EEP_read (stat.addr * sizeof(uint16_t), eep_buf, EEP_READ_SIZE) != 0) {
               stat.contstat.bits.ackErr = 1;
            } else {
               ESC_write (ESCREG_EEDATA, eep_buf, EEP_READ_SIZE);
            }
            break;

         case EEP_CMD_WRITE:
            /* handle write request */
            ESC_read (ESCREG_EEDATA, eep_buf, EEP_WRITE_SIZE);
            if (EEP_write (stat.addr * sizeof(uint16_t), eep_buf, EEP_WRITE_SIZE) != 0) {
               stat.contstat.bits.ackErr = 1;
            }
            break;

         default:
            stat.contstat.bits.ackErr = 1;
      }

      /* acknowledge command */
      stat.contstat.reg = htoes(stat.contstat.reg);
      ESC_write (ESCREG_EECONTSTAT, &stat.contstat.reg, sizeof(uint16_t));
   }
}
Beispiel #3
0
/** TBD
 */
void ESC_ackmbxread (void)
{
   uint8_t dummy = 0;
   if (ESCvar.ALstatus == ESCboot)
   {
      ESC_write (MBX1_sma_b, &dummy, 1, (void *) &ESCvar.ALevent);
   }
   else
   {
      ESC_write (MBX1_sma, &dummy, 1, (void *) &ESCvar.ALevent);
   }
   ESCvar.mbxfree = 1;
}
Beispiel #4
0
/** Write AL Status Code to the ESC.
 *
 * @param[in] errornumber   = Write an by EtherCAT specified Error number register 0x134 AL Status Code
 */
void ESC_ALerror (uint16_t errornumber)
{
   uint16_t dummy;
   ESCvar.ALerror = errornumber;
   dummy = htoes (errornumber);
   ESC_write (ESCREG_ALERROR, &dummy, sizeof (dummy), (void *) &ESCvar.ALevent);
}
Beispiel #5
0
/** Write ESCvar.SM[n] data to ESC PDI control register 0x807(+ offset to SyncManager n).
 *
 * @param[in] n   = Write to Sync Manager no. n
 */
void ESC_SMwritepdi (uint8_t n)
{
   _ESCsm2 *sm;
   sm = (_ESCsm2 *) & ESCvar.SM[n];
   ESC_write (ESCREG_SM0PDI + (n << 3), &(sm->ActPDI), 1,
              (void *) &ESCvar.ALevent);
}
Beispiel #6
0
/** Write AL Status to the ESC.
 *
 * @param[in] status   = Write current slave status to register 0x130 AL Status
 * reflecting actual state and error indication if present
 */
void ESC_ALstatus (uint8_t status)
{
   uint16_t dummy;
   ESCvar.ALstatus = status;
   dummy = htoes ((uint16_t) status);
   ESC_write (ESCREG_ALSTATUS, &dummy, sizeof (dummy),
              (void *) &ESCvar.ALevent);
}
Beispiel #7
0
/** Mandatory: Write local process data to Sync Manager 3, Master Inputs.
 */
void TXPDO_update (void)
{
   if(ESCvar.txpdo_override != NULL)
   {
      (ESCvar.txpdo_override)();
   }
   else
   {
      ESC_write (SM3_sma, &Rb, ESCvar.TXPDOsize);
   }
}
Beispiel #8
0
/** Mandatory: Write local process data to Sync Manager 3, Master Inputs.
 */
void TXPDO_update (void)
{
   ESC_write (SM3_sma, &Rb.button, TXPDOsize);
}
Beispiel #9
0
/** Mandatory: Write local process data to Sync Manager 3, Master Inputs.
 */
void TXPDO_update (void)
{
   ESC_write (SM3_sma, &Rb.button, TXPDOsize, (void *) &ESCvar.ALevent);
}