int spirit_gpio_enable_clockoutput(FAR struct spirit_library_s *spirit, enum spirit_functional_state_e newstate) { uint8_t regval; int ret; /* Check the parameters */ DEBUGASSERT(IS_SPIRIT_FUNCTIONAL_STATE(newstate)); /* Reads the MCU_CK_CONF register and mask the result to enable or disable * the clock output */ ret = spirit_reg_read(spirit, MCU_CK_CONF_BASE, ®val, 1); if (ret >= 0) { if (newstate) { regval |= MCU_CK_ENABLE; } else { regval &= (~MCU_CK_ENABLE); } /* Write to the MCU_CK_CONF register */ ret = spirit_reg_write(spirit, MCU_CK_CONF_BASE, ®val, 1); } return ret; }
/** * @brief Enables or Disables the output of temperature sensor on SPIRIT GPIO_0. * @param xNewState new state for temperature sensor. * This parameter can be: S_ENABLE or S_DISABLE. * @retval None. */ void SpiritGpioTemperatureSensor(SpiritFunctionalState xNewState) { uint8_t tempRegValue = 0x00; uint8_t gpio0tempRegValue = 0x00; /* Check the parameters */ s_assert_param(IS_SPIRIT_FUNCTIONAL_STATE(xNewState)); /* Reads the ANA_FUNC_CONF0 register and mask the result to enable or disable the temperature sensor */ g_xStatus = SpiritSpiReadRegisters(ANA_FUNC_CONF0_BASE, 1, &tempRegValue); if(xNewState == S_ENABLE) { tempRegValue |= TEMPERATURE_SENSOR_MASK; } else { tempRegValue &= (~TEMPERATURE_SENSOR_MASK); gpio0tempRegValue = 0x0A; /* Default value */ } g_xStatus = SpiritSpiWriteRegisters(ANA_FUNC_CONF0_BASE, 1, &tempRegValue); /* Sets the SPIRIT GPIO_0 according to input request */ g_xStatus = SpiritSpiWriteRegisters(GPIO0_CONF_BASE, 1, &gpio0tempRegValue); }
/** * @brief If enabled RX packet is accepted only if the masked control field matches the * masked control field reference (CONTROL_MASK & CONTROL_FIELD_REF == CONTROL_MASK & RX_CONTROL_FIELD). * @param xNewState new state for Control filtering enable bit. * This parameter can be S_ENABLE or S_DISABLE. * @retval None. * @note This filtering control is enabled by default but the control mask is by default set to 0. * As a matter of fact the user has to enable the control filtering bit after the packet initialization * because the PktInit routine disables it. */ void SpiritPktCommonFilterOnControlField(SpiritFunctionalState xNewState) { uint8_t tempRegValue; /* Check the parameters */ s_assert_param(IS_SPIRIT_FUNCTIONAL_STATE(xNewState)); /* Modify the register value: set or reset the control bit filtering */ g_xStatus = SpiritSpiReadRegisters(PCKT_FLT_OPTIONS_BASE, 1, &tempRegValue); /* Set or reset the CONTROL filtering enabling bit */ if(xNewState == S_ENABLE) { tempRegValue |= PCKT_FLT_OPTIONS_CONTROL_FILTERING_MASK; } else { tempRegValue &= ~PCKT_FLT_OPTIONS_CONTROL_FILTERING_MASK; } /* Writes the new value on the PCKT_FLT_OPTIONS register */ g_xStatus = SpiritSpiWriteRegisters(PCKT_FLT_OPTIONS_BASE, 1, &tempRegValue); }
/** * @brief If enabled RX packet is accepted if its destination address matches with My address. * @param xNewState new state for DEST_VS_SOURCE_ADDRESS. * This parameter can be S_ENABLE or S_DISABLE. * @retval None. */ void SpiritPktCommonFilterOnMyAddress(SpiritFunctionalState xNewState) { uint8_t tempRegValue; /* Check the parameters */ s_assert_param(IS_SPIRIT_FUNCTIONAL_STATE(xNewState)); /* Modify the register value: set or reset the TX source address control */ g_xStatus = SpiritSpiReadRegisters(PCKT_FLT_OPTIONS_BASE, 1, &tempRegValue); /* Set or reset the DESTINATION vs TX enabling bit */ if(xNewState == S_ENABLE) { tempRegValue |= PCKT_FLT_OPTIONS_DEST_VS_TX_ADDR_MASK; } else { tempRegValue &= ~PCKT_FLT_OPTIONS_DEST_VS_TX_ADDR_MASK; } /* Writes the new value on the PCKT_FLT_OPTIONS register */ g_xStatus = SpiritSpiWriteRegisters(PCKT_FLT_OPTIONS_BASE, 1, &tempRegValue); }
/** * @brief Sets the AUTO ACKNOLEDGEMENT mechanism on the receiver. When the feature is enabled and * a data packet has been correctly received, then an acknowledgement packet is sent back to the originator of the received * packet. If the PIGGYBACKING bit is also set, payload data will be read from the FIFO; otherwise an empty packet is sent * only containing the source and destination addresses and the sequence number of the packet being acknowledged. * @param xAutoAck new state for autoack. * This parameter can be: S_ENABLE or S_DISABLE. * @param xPiggybacking new state for autoack. * This parameter can be: S_ENABLE or S_DISABLE. * @retval None. */ void SpiritPktCommonAutoAck(SpiritFunctionalState xAutoAck , SpiritFunctionalState xPiggybacking) { uint8_t tempRegValue[2]; /* Check the parameters */ s_assert_param(IS_SPIRIT_FUNCTIONAL_STATE(xAutoAck)); s_assert_param(IS_SPIRIT_FUNCTIONAL_STATE(xPiggybacking)); /* Check if piggybacking is enabled and autoack is disabled */ s_assert_param(!(xPiggybacking==S_ENABLE && xAutoAck==S_DISABLE)); /* Reads the PROTOCOL[1:0] registers value */ g_xStatus = SpiritSpiReadRegisters(PROTOCOL1_BASE, 2, tempRegValue); /* Sets the specified LLP option */ /* Autoack setting */ if(xAutoAck == S_ENABLE) { tempRegValue[1] |= PROTOCOL0_AUTO_ACK_MASK; } else { tempRegValue[1] &= (~PROTOCOL0_AUTO_ACK_MASK); } /* Piggybacking setting */ if(xPiggybacking == S_ENABLE) { tempRegValue[0] |= PROTOCOL1_PIGGYBACKING_MASK; } else { tempRegValue[0] &= (~PROTOCOL1_PIGGYBACKING_MASK); } /* Writes data on the PROTOCOL[1:0] registers */ g_xStatus = SpiritSpiWriteRegisters(PROTOCOL1_BASE, 2, tempRegValue); }
/** * @brief Enables or Disables the MCU clock output. * @param xNewState new state for the MCU clock output. * This parameter can be: S_ENABLE or S_DISABLE. * @retval None. */ void SpiritGpioClockOutput(SpiritFunctionalState xNewState) { uint8_t tempRegValue; /* Check the parameters */ s_assert_param(IS_SPIRIT_FUNCTIONAL_STATE(xNewState)); /* Reads the MCU_CK_CONF register and mask the result to enable or disable the clock output */ g_xStatus = SpiritSpiReadRegisters(MCU_CK_CONF_BASE, 1, &tempRegValue); if(xNewState) tempRegValue |= MCU_CK_ENABLE; else tempRegValue &= (~MCU_CK_ENABLE); /* Writes the MCU_CK_CONF register */ g_xStatus = SpiritSpiWriteRegisters(MCU_CK_CONF_BASE, 1, &tempRegValue); }
/** * @brief Enables or disables a specific IRQ. * @param xIrq IRQ to enable or disable. * This parameter can be any value of @ref IrqList. * @param xNewState new state for the IRQ. * This parameter can be: S_ENABLE or S_DISABLE. * @retval None. */ void SpiritIrq(IrqList xIrq, SpiritFunctionalState xNewState) { uint8_t tempRegValue[4]; uint32_t tempValue = 0; /* Check the parameters */ s_assert_param(IS_SPIRIT_IRQ_LIST(xIrq)); s_assert_param(IS_SPIRIT_FUNCTIONAL_STATE(xNewState)); /* Reads the IRQ_MASK registers */ g_xStatus = SpiritSpiReadRegisters(IRQ_MASK3_BASE, 4, tempRegValue); /* Build the IRQ mask word */ for(uint8_t i=0; i<4; i++) { tempValue += ((uint32_t)tempRegValue[i])<<(8*(3-i)); } /* Rebuild the new mask according to user request */ if(xNewState == S_DISABLE) { tempValue &= (~xIrq); } else { tempValue |= (xIrq); } /* Build the array of bytes to write in the IRQ_MASK registers */ for(uint8_t j=0; j<4; j++) { tempRegValue[j] = (uint8_t)(tempValue>>(8*(3-j))); } /* Writes the new IRQ mask in the corresponding registers */ g_xStatus = SpiritSpiWriteRegisters(IRQ_MASK3_BASE, 4, tempRegValue); }
int spirit_gpio_enable_tempsensor(FAR struct spirit_library_s *spirit, enum spirit_functional_state_e newstate) { uint8_t regval = 0; uint8_t gpio0regval = 0; int ret; /* Check the parameters */ DEBUGASSERT(IS_SPIRIT_FUNCTIONAL_STATE(newstate)); /* Reads the ANA_FUNC_CONF0 register and mask the result to enable or disable * the temperature sensor */ ret = spirit_reg_read(spirit, ANA_FUNC_CONF0_BASE, ®val, 1); if (ret >= 0) { if (newstate == S_ENABLE) { regval |= TEMPERATURE_SENSOR_MASK; } else { regval &= (~TEMPERATURE_SENSOR_MASK); gpio0regval = 0x0a; /* Default value */ } ret = spirit_reg_write(spirit, ANA_FUNC_CONF0_BASE, ®val, 1); if (ret >= 0) { /* Sets the SPIRIT GPIO_0 according to input request */ ret = spirit_reg_write(spirit, GPIO0_CONF_BASE, &gpio0regval, 1); } } return ret; }
/** * @brief Enables or Disables the output of battery level detector. * @param xNewState new state for battery level detector. * This parameter can be: S_ENABLE or S_DISABLE. * @retval None */ void SpiritGeneralBatteryLevel(SpiritFunctionalState xNewState) { uint8_t tempRegValue; /* Check the parameters */ s_assert_param(IS_SPIRIT_FUNCTIONAL_STATE(xNewState)); /* Reads the ANA_FUNC_CONF0_BASE register value */ g_xStatus = SpiritSpiReadRegisters(ANA_FUNC_CONF0_BASE, 1, &tempRegValue); /* Build the value to be stored */ if(xNewState == S_ENABLE) { tempRegValue |= BATTERY_LEVEL_MASK; } else { tempRegValue &= ~BATTERY_LEVEL_MASK; } /* Writes the new value */ g_xStatus = SpiritSpiWriteRegisters(ANA_FUNC_CONF0_BASE, 1, &tempRegValue); }
/** * @brief Enables/Disables the Synchronization Quality Indicator check. The running peak SQI is * compared to a threshold value and the sync valid IRQ is asserted as soon as the threshold is passed. * @param xNewState new state for SQI check. * This parameter can be: S_ENABLE or S_DISABLE. * @retval None. */ void SpiritQiSqiCheck(SpiritFunctionalState xNewState) { uint8_t tempRegValue; /* Check the parameters */ s_assert_param(IS_SPIRIT_FUNCTIONAL_STATE(xNewState)); /* Reads the QI register value */ g_xStatus = SpiritSpiReadRegisters(QI_BASE, 1, &tempRegValue); /* Enables or disables the SQI Check bit on the QI_BASE register */ if(xNewState == S_ENABLE) { tempRegValue |= QI_SQI_MASK; } else { tempRegValue &= ~QI_SQI_MASK; } /* Writes value on the QI register */ g_xStatus = SpiritSpiWriteRegisters(QI_BASE, 1, &tempRegValue); }
/** * @brief Sets the AUTO ACKNOLEDGEMENT mechanism on the transmitter. On the transmitter side, the NACK_TX field can be used to require or not an acknowledgment for each individual packet: if * NACK_TX is set to "1" then acknowledgment will not be required; if NACK_TX is set to "0" then acknowledgment will be * required. * @param xNewState new state for TX_AUTOACK. * This parameter can be: S_ENABLE or S_DISABLE. * @retval None. */ void SpiritPktCommonRequireAck(SpiritFunctionalState xNewState) { uint8_t tempRegValue; /* Check the parameters */ s_assert_param(IS_SPIRIT_FUNCTIONAL_STATE(xNewState)); /* Reads value on the PROTOCOL0 register */ g_xStatus = SpiritSpiReadRegisters(PROTOCOL0_BASE, 1, &tempRegValue); /* Enables or disables the ack requirement option */ if(xNewState == S_DISABLE) { tempRegValue |= PROTOCOL0_NACK_TX_MASK; } else { tempRegValue &= ~PROTOCOL0_NACK_TX_MASK; } /* Writes value on the PROTOCOL0 register */ g_xStatus = SpiritSpiWriteRegisters(PROTOCOL0_BASE, 1, &tempRegValue); }
/** * @brief Sets High Power Mode. * @param xNewState new state for High Power Mode. * This parameter can be: S_ENABLE or S_DISABLE. * @retval None. */ void SpiritGeneralHighPwr(SpiritFunctionalState xNewState) { uint8_t tempRegValue; /* Check the parameters */ s_assert_param(IS_SPIRIT_FUNCTIONAL_STATE(xNewState)); /* Reads the ANA_FUNC_CONF0_BASE register value */ g_xStatus = SpiritSpiReadRegisters(ANA_FUNC_CONF0_BASE, 1, &tempRegValue); /* Build the value to write */ if(xNewState == S_ENABLE) { tempRegValue |= HIGH_POWER_MODE_MASK; } else { tempRegValue &= ~HIGH_POWER_MODE_MASK; } /* Writes the new value on register */ g_xStatus = SpiritSpiWriteRegisters(ANA_FUNC_CONF0_BASE, 1, &tempRegValue); }
/** * @brief Enables/Disables the SQI Timeout Mask. If enabled SQI value contributes to timeout disabling. * @param xNewState new state for SQI Timeout Mask. * This parameter can be S_ENABLE or S_DISABLE. * @retval None. */ void SpiritQiSqiTimeoutMask(SpiritFunctionalState xNewState) { uint8_t tempRegValue; /* Check the parameters */ s_assert_param(IS_SPIRIT_FUNCTIONAL_STATE(xNewState)); /* Reads the PROTOCOL2 register */ g_xStatus = SpiritSpiReadRegisters(PROTOCOL2_BASE, 1, &tempRegValue); /* Enables or disables the SQI timeout mask */ if(xNewState == S_ENABLE) { tempRegValue |= PROTOCOL2_SQI_TIMEOUT_MASK; } else { tempRegValue &= ~PROTOCOL2_SQI_TIMEOUT_MASK; } /* Writes the new value on the PROTOCOL2 register */ g_xStatus = SpiritSpiWriteRegisters(PROTOCOL2_BASE, 1, &tempRegValue); }
/** * @brief If enabled RX packet is accepted if its destination address matches with broadcast address. * @param xNewState new state for DEST_VS_BROADCAST_ADDRESS. * This parameter can be S_ENABLE or S_DISABLE. * @retval None. */ void SpiritPktCommonFilterOnBroadcastAddress(SpiritFunctionalState xNewState) { uint8_t tempRegValue; /* Check the parameters */ s_assert_param(IS_SPIRIT_FUNCTIONAL_STATE(xNewState)); /* Reads the register value */ g_xStatus = SpiritSpiReadRegisters(PCKT_FLT_OPTIONS_BASE, 1, &tempRegValue); /* Enable or disable the filtering option */ if(xNewState == S_ENABLE) { tempRegValue |= PCKT_FLT_OPTIONS_DEST_VS_BROADCAST_ADDR_MASK; } else { tempRegValue &= ~PCKT_FLT_OPTIONS_DEST_VS_BROADCAST_ADDR_MASK; } /* Writes the new value on the PCKT_FLT_OPTIONS register */ g_xStatus = SpiritSpiWriteRegisters(PCKT_FLT_OPTIONS_BASE, 1, &tempRegValue); }
/** * @brief Enables or Disables FEC for SPIRIT packets. * @param xNewState new state for FEC mode. * This parameter can be S_ENABLE or S_DISABLE. * @retval None. */ void SpiritPktCommonFec(SpiritFunctionalState xNewState) { uint8_t tempRegValue; /* Check the parameters */ s_assert_param(IS_SPIRIT_FUNCTIONAL_STATE(xNewState)); /* Reads the PCKTCTRL1 register value */ g_xStatus = SpiritSpiReadRegisters(PCKTCTRL1_BASE, 1, &tempRegValue); /* Build data to write: set or reset the FEC enable bit */ if(xNewState == S_ENABLE) { tempRegValue |= PCKTCTRL1_FEC_MASK; } else { tempRegValue &= ~PCKTCTRL1_FEC_MASK; } /* Writes data on the PCKTCTRL1 register */ g_xStatus = SpiritSpiWriteRegisters(PCKTCTRL1_BASE, 1, &tempRegValue); }
/** * @brief Enables or Disables the filtering on CRC. * @param xNewState new state for CRC_CHECK. * This parameter can be S_ENABLE or S_DISABLE. * @retval None. */ void SpiritPktCommonFilterOnCrc(SpiritFunctionalState xNewState) { uint8_t tempRegValue; /* Check the parameters */ s_assert_param(IS_SPIRIT_FUNCTIONAL_STATE(xNewState)); /* Reads the PCKT_FLT_OPTIONS register value */ g_xStatus = SpiritSpiReadRegisters(PCKT_FLT_OPTIONS_BASE, 1, &tempRegValue); /* Modify the register value: enable or disable the CRC filtering */ if(xNewState == S_ENABLE) { tempRegValue |= PCKT_FLT_OPTIONS_CRC_CHECK_MASK; } else { tempRegValue &= ~PCKT_FLT_OPTIONS_CRC_CHECK_MASK; } /* Writes the PCKT_FLT_OPTIONS register value */ g_xStatus = SpiritSpiWriteRegisters(PCKT_FLT_OPTIONS_BASE, 1, &tempRegValue); }
/** * @brief Initializes the SPIRIT STack packet according to the specified * parameters in the PktStackInit. * @param pxPktStackInit STack packet init structure. * This parameter is a pointer to @ref PktStackInit. * @retval None. */ void SpiritPktStackInit(PktStackInit* pxPktStackInit) { uint8_t tempRegValue[10], i; /* Check the parameters */ s_assert_param(IS_STACK_PREAMBLE_LENGTH(pxPktStackInit->xPreambleLength)); s_assert_param(IS_STACK_SYNC_LENGTH(pxPktStackInit->xSyncLength)); s_assert_param(IS_STACK_CRC_MODE(pxPktStackInit->xCrcMode)); s_assert_param(IS_STACK_LENGTH_WIDTH_BITS(pxPktStackInit->cPktLengthWidth)); s_assert_param(IS_STACK_FIX_VAR_LENGTH(pxPktStackInit->xFixVarLength)); s_assert_param(IS_SPIRIT_FUNCTIONAL_STATE(pxPktStackInit->xFec)); s_assert_param(IS_SPIRIT_FUNCTIONAL_STATE(pxPktStackInit->xDataWhitening)); s_assert_param(IS_STACK_CONTROL_LENGTH(pxPktStackInit->xControlLength)); /* Reads the PROTOCOL1 register */ g_xStatus = SpiritSpiReadRegisters(PROTOCOL1_BASE, 1, &tempRegValue[0]); /* Mask a reserved bit */ tempRegValue[0] &= ~0x20; /* Always (!) set the automatic packet filtering */ tempRegValue[0] |= PROTOCOL1_AUTO_PCKT_FLT_MASK; /* Writes the value on register */ g_xStatus = SpiritSpiWriteRegisters(PROTOCOL1_BASE, 1, &tempRegValue[0]); /* Reads the PCKT_FLT_OPTIONS register */ g_xStatus = SpiritSpiReadRegisters(PCKT_FLT_OPTIONS_BASE, 1, &tempRegValue[0]); /* Always reset the control and source filtering */ tempRegValue[0] &= ~(PCKT_FLT_OPTIONS_SOURCE_FILTERING_MASK | PCKT_FLT_OPTIONS_CONTROL_FILTERING_MASK); /* Writes the value on register */ g_xStatus = SpiritSpiWriteRegisters(PCKT_FLT_OPTIONS_BASE, 1, &tempRegValue[0]); /* Address and control length setting: source and destination address are always present so ADDRESS_LENGTH=2 */ tempRegValue[0] = 0x10 | ((uint8_t) pxPktStackInit->xControlLength); /* Packet format and width length setting */ pxPktStackInit->cPktLengthWidth == 0 ? pxPktStackInit->cPktLengthWidth=1 : pxPktStackInit->cPktLengthWidth; tempRegValue[1] = ((uint8_t) PCKTCTRL3_PCKT_FRMT_STACK) | ((uint8_t)(pxPktStackInit->cPktLengthWidth-1)); /* Preamble, sync and fixed or variable length setting */ tempRegValue[2] = ((uint8_t) pxPktStackInit->xPreambleLength) | ((uint8_t) pxPktStackInit->xSyncLength) | ((uint8_t) pxPktStackInit->xFixVarLength); /* CRC length, whitening and FEC setting */ tempRegValue[3] = (uint8_t) pxPktStackInit->xCrcMode; if(pxPktStackInit->xDataWhitening == S_ENABLE) { tempRegValue[3] |= PCKTCTRL1_WHIT_MASK; } if(pxPktStackInit->xFec == S_ENABLE) { tempRegValue[3] |= PCKTCTRL1_FEC_MASK; } /* Payload length padding. This sets the payload length to 0 and is used to do a single SPI transation. */ tempRegValue[4] = 0x00; tempRegValue[5] = 0x00; /* Sync words setting */ for(i=0;i<4;i++){ if(i<3-(pxPktStackInit->xSyncLength >>1)) tempRegValue[6+i]=0; else tempRegValue[6+i] = (uint8_t)(pxPktStackInit->lSyncWords>>(8*i)); }
/** * @brief Initializes the SPIRIT Basic packet according to the specified parameters in the PktBasicInit struct. * Notice that this function sets the autofiltering option on CRC if it is set to any value different from BASIC_NO_CRC. * @param pxPktBasicInit Basic packet init structure. * This parameter is a pointer to @ref PktBasicInit. * @retval None. */ void SpiritPktBasicInit(PktBasicInit* pxPktBasicInit) { uint8_t tempRegValue[4], i; /* Check the parameters */ s_assert_param(IS_BASIC_PREAMBLE_LENGTH(pxPktBasicInit->xPreambleLength)); s_assert_param(IS_BASIC_SYNC_LENGTH(pxPktBasicInit->xSyncLength)); s_assert_param(IS_BASIC_CRC_MODE(pxPktBasicInit->xCrcMode)); s_assert_param(IS_BASIC_LENGTH_WIDTH_BITS(pxPktBasicInit->cPktLengthWidth)); s_assert_param(IS_BASIC_FIX_VAR_LENGTH(pxPktBasicInit->xFixVarLength)); s_assert_param(IS_SPIRIT_FUNCTIONAL_STATE(pxPktBasicInit->xAddressField)); s_assert_param(IS_SPIRIT_FUNCTIONAL_STATE(pxPktBasicInit->xFec)); s_assert_param(IS_SPIRIT_FUNCTIONAL_STATE(pxPktBasicInit->xDataWhitening)); s_assert_param(IS_BASIC_CONTROL_LENGTH(pxPktBasicInit->xControlLength)); /* Reads the PROTOCOL1 register */ g_xStatus = SpiritSpiReadRegisters(PROTOCOL1_BASE, 1, &tempRegValue[0]); /* Mask a reserved bit */ tempRegValue[0] &= ~0x20; /* Always set the automatic packet filtering */ tempRegValue[0] |= PROTOCOL1_AUTO_PCKT_FLT_MASK; /* Writes the value on register */ g_xStatus = SpiritSpiWriteRegisters(PROTOCOL1_BASE, 1, &tempRegValue[0]); /* Reads the PCKT_FLT_OPTIONS register */ g_xStatus = SpiritSpiReadRegisters(PCKT_FLT_OPTIONS_BASE, 1, &tempRegValue[0]); /* Always reset the control and source filtering (also if it is not present in basic) */ tempRegValue[0] &= ~(PCKT_FLT_OPTIONS_SOURCE_FILTERING_MASK | PCKT_FLT_OPTIONS_CONTROL_FILTERING_MASK); /* Writes the value on register */ g_xStatus = SpiritSpiWriteRegisters(PCKT_FLT_OPTIONS_BASE, 1, &tempRegValue[0]); if(pxPktBasicInit->xAddressField == S_ENABLE) { tempRegValue[0]=0x08; } else { tempRegValue[0]=0x00; } /* Address and control length setting */ tempRegValue[0] |= ((uint8_t) pxPktBasicInit->xControlLength); /* Packet format and width length setting */ pxPktBasicInit->cPktLengthWidth == 0 ? pxPktBasicInit->cPktLengthWidth=1 : pxPktBasicInit->cPktLengthWidth; tempRegValue[1] = ((uint8_t) PCKTCTRL3_PCKT_FRMT_BASIC) | ((uint8_t)(pxPktBasicInit->cPktLengthWidth-1)); /* Preamble, sync and fixed or variable length setting */ tempRegValue[2] = ((uint8_t) pxPktBasicInit->xPreambleLength) | ((uint8_t) pxPktBasicInit->xSyncLength) | ((uint8_t) pxPktBasicInit->xFixVarLength); /* CRC length, whitening and FEC setting */ tempRegValue[3] = (uint8_t) pxPktBasicInit->xCrcMode; if(pxPktBasicInit->xDataWhitening == S_ENABLE) { tempRegValue[3] |= PCKTCTRL1_WHIT_MASK; } if(pxPktBasicInit->xFec == S_ENABLE) { tempRegValue[3] |= PCKTCTRL1_FEC_MASK; } /* Writes registers */ SpiritSpiWriteRegisters(PCKTCTRL4_BASE, 4, tempRegValue); /* Sync words setting */ for(i=0;i<4;i++) { if(i<3-(pxPktBasicInit->xSyncLength >>1)) { tempRegValue[i]=0; } else { tempRegValue[i] = (uint8_t)(pxPktBasicInit->lSyncWords>>(8*i)); } }