Add const qualifier to the parameters of Projects' functions where possible.
This commit is contained in:
		
							parent
							
								
									e73f05b8b2
								
							
						
					
					
						commit
						b408a5fe62
					
				
					 19 changed files with 73 additions and 70 deletions
				
			
		| 
						 | 
				
			
			@ -66,11 +66,11 @@
 | 
			
		|||
	/* Function Prototypes: */
 | 
			
		||||
		void ISPProtocol_EnterISPMode(void);
 | 
			
		||||
		void ISPProtocol_LeaveISPMode(void);
 | 
			
		||||
		void ISPProtocol_ProgramMemory(uint8_t V2Command);
 | 
			
		||||
		void ISPProtocol_ReadMemory(uint8_t V2Command);
 | 
			
		||||
		void ISPProtocol_ProgramMemory(const uint8_t V2Command);
 | 
			
		||||
		void ISPProtocol_ReadMemory(const uint8_t V2Command);
 | 
			
		||||
		void ISPProtocol_ChipErase(void);
 | 
			
		||||
		void ISPProtocol_ReadFuseLockSigOSCCAL(uint8_t V2Command);
 | 
			
		||||
		void ISPProtocol_WriteFuseLock(uint8_t V2Command);
 | 
			
		||||
		void ISPProtocol_ReadFuseLockSigOSCCAL(const uint8_t V2Command);
 | 
			
		||||
		void ISPProtocol_WriteFuseLock(const uint8_t V2Command);
 | 
			
		||||
		void ISPProtocol_SPIMulti(void);
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -80,7 +80,7 @@ uint8_t ISPTarget_GetSPIPrescalerMask(void)
 | 
			
		|||
 *
 | 
			
		||||
 *  \param[in] ResetTarget Boolean true when the target should be held in reset, false otherwise
 | 
			
		||||
 */
 | 
			
		||||
void ISPTarget_ChangeTargetResetLine(bool ResetTarget)
 | 
			
		||||
void ISPTarget_ChangeTargetResetLine(const bool ResetTarget)
 | 
			
		||||
{
 | 
			
		||||
	if (ResetTarget)
 | 
			
		||||
	{
 | 
			
		||||
| 
						 | 
				
			
			@ -108,8 +108,8 @@ void ISPTarget_ChangeTargetResetLine(bool ResetTarget)
 | 
			
		|||
 *  \return V2 Protocol status \ref STATUS_CMD_OK if the no timeout occurred, \ref STATUS_RDY_BSY_TOUT or
 | 
			
		||||
 *          \ref STATUS_CMD_TOUT otherwise
 | 
			
		||||
 */
 | 
			
		||||
uint8_t ISPTarget_WaitForProgComplete(uint8_t ProgrammingMode, uint16_t PollAddress, uint8_t PollValue,
 | 
			
		||||
                                      uint8_t DelayMS, uint8_t ReadMemCommand)
 | 
			
		||||
uint8_t ISPTarget_WaitForProgComplete(const uint8_t ProgrammingMode, const uint16_t PollAddress, const uint8_t PollValue,
 | 
			
		||||
                                      const uint8_t DelayMS, const uint8_t ReadMemCommand)
 | 
			
		||||
{
 | 
			
		||||
	uint8_t ProgrammingStatus = STATUS_CMD_OK;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -62,9 +62,10 @@
 | 
			
		|||
 | 
			
		||||
	/* Function Prototypes: */
 | 
			
		||||
			uint8_t ISPTarget_GetSPIPrescalerMask(void);
 | 
			
		||||
			void    ISPTarget_ChangeTargetResetLine(bool ResetTarget);
 | 
			
		||||
			uint8_t ISPTarget_WaitForProgComplete(uint8_t ProgrammingMode, uint16_t PollAddress, uint8_t PollValue,
 | 
			
		||||
                                                   uint8_t DelayMS, uint8_t ReadMemCommand);
 | 
			
		||||
			void    ISPTarget_ChangeTargetResetLine(const bool ResetTarget);
 | 
			
		||||
			uint8_t ISPTarget_WaitForProgComplete(const uint8_t ProgrammingMode, const uint16_t PollAddress,
 | 
			
		||||
			                                      const uint8_t PollValue, const uint8_t DelayMS,
 | 
			
		||||
			                                      const uint8_t ReadMemCommand);
 | 
			
		||||
			uint8_t ISPTarget_WaitWhileTargetBusy(void);
 | 
			
		||||
			void    ISPTarget_LoadExtendedAddress(void);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -42,7 +42,7 @@
 | 
			
		|||
 *
 | 
			
		||||
 *  \param[in] Register  NVM register whose absolute address is to be sent
 | 
			
		||||
 */
 | 
			
		||||
void NVMTarget_SendNVMRegAddress(uint8_t Register)
 | 
			
		||||
void NVMTarget_SendNVMRegAddress(const uint8_t Register)
 | 
			
		||||
{
 | 
			
		||||
	/* Determine the absolute register address from the NVM base memory address and the NVM register address */
 | 
			
		||||
	uint32_t Address = XPROG_Param_NVMBase | Register;
 | 
			
		||||
| 
						 | 
				
			
			@ -55,7 +55,7 @@ void NVMTarget_SendNVMRegAddress(uint8_t Register)
 | 
			
		|||
 *
 | 
			
		||||
 *  \param[in] AbsoluteAddress  Absolute address to send to the target
 | 
			
		||||
 */
 | 
			
		||||
void NVMTarget_SendAddress(uint32_t AbsoluteAddress)
 | 
			
		||||
void NVMTarget_SendAddress(const uint32_t AbsoluteAddress)
 | 
			
		||||
{
 | 
			
		||||
	/* Send the given 32-bit address to the target, LSB first */
 | 
			
		||||
	PDITarget_SendByte(AbsoluteAddress &  0xFF);
 | 
			
		||||
| 
						 | 
				
			
			@ -95,7 +95,7 @@ bool NVMTarget_WaitWhileNVMControllerBusy(void)
 | 
			
		|||
 *
 | 
			
		||||
 *  \return Boolean true if the command sequence complete successfully
 | 
			
		||||
 */
 | 
			
		||||
bool NVMTarget_GetMemoryCRC(uint8_t CRCCommand, uint32_t* CRCDest)
 | 
			
		||||
bool NVMTarget_GetMemoryCRC(const uint8_t CRCCommand, uint32_t* const CRCDest)
 | 
			
		||||
{
 | 
			
		||||
	/* Wait until the NVM controller is no longer busy */
 | 
			
		||||
	if (!(NVMTarget_WaitWhileNVMControllerBusy()))
 | 
			
		||||
| 
						 | 
				
			
			@ -147,7 +147,7 @@ bool NVMTarget_GetMemoryCRC(uint8_t CRCCommand, uint32_t* CRCDest)
 | 
			
		|||
 *
 | 
			
		||||
 *  \return Boolean true if the command sequence complete successfully
 | 
			
		||||
 */
 | 
			
		||||
bool NVMTarget_ReadMemory(uint32_t ReadAddress, uint8_t* ReadBuffer, uint16_t ReadSize)
 | 
			
		||||
bool NVMTarget_ReadMemory(const uint32_t ReadAddress, uint8_t* ReadBuffer, const uint16_t ReadSize)
 | 
			
		||||
{
 | 
			
		||||
	/* Wait until the NVM controller is no longer busy */
 | 
			
		||||
	if (!(NVMTarget_WaitWhileNVMControllerBusy()))
 | 
			
		||||
| 
						 | 
				
			
			@ -182,7 +182,7 @@ bool NVMTarget_ReadMemory(uint32_t ReadAddress, uint8_t* ReadBuffer, uint16_t Re
 | 
			
		|||
 *
 | 
			
		||||
 *  \return Boolean true if the command sequence complete successfully
 | 
			
		||||
 */
 | 
			
		||||
bool NVMTarget_WriteByteMemory(uint8_t WriteCommand, uint32_t WriteAddress, uint8_t* WriteBuffer)
 | 
			
		||||
bool NVMTarget_WriteByteMemory(const uint8_t WriteCommand, const uint32_t WriteAddress, const uint8_t* WriteBuffer)
 | 
			
		||||
{
 | 
			
		||||
	/* Wait until the NVM controller is no longer busy */
 | 
			
		||||
	if (!(NVMTarget_WaitWhileNVMControllerBusy()))
 | 
			
		||||
| 
						 | 
				
			
			@ -195,7 +195,7 @@ bool NVMTarget_WriteByteMemory(uint8_t WriteCommand, uint32_t WriteAddress, uint
 | 
			
		|||
	
 | 
			
		||||
	/* Send new memory byte to the memory to the target */
 | 
			
		||||
	PDITarget_SendByte(PDI_CMD_STS | (PDI_DATSIZE_4BYTES << 2));
 | 
			
		||||
	NVMTarget_SendAddress(WriteAddress++);
 | 
			
		||||
	NVMTarget_SendAddress(WriteAddress);
 | 
			
		||||
	PDITarget_SendByte(*(WriteBuffer++));
 | 
			
		||||
	
 | 
			
		||||
	return true;
 | 
			
		||||
| 
						 | 
				
			
			@ -213,8 +213,9 @@ bool NVMTarget_WriteByteMemory(uint8_t WriteCommand, uint32_t WriteAddress, uint
 | 
			
		|||
 *
 | 
			
		||||
 *  \return Boolean true if the command sequence complete successfully
 | 
			
		||||
 */
 | 
			
		||||
bool NVMTarget_WritePageMemory(uint8_t WriteBuffCommand, uint8_t EraseBuffCommand, uint8_t WritePageCommand,
 | 
			
		||||
                               uint8_t PageMode, uint32_t WriteAddress, uint8_t* WriteBuffer, uint16_t WriteSize)
 | 
			
		||||
bool NVMTarget_WritePageMemory(const uint8_t WriteBuffCommand, const uint8_t EraseBuffCommand,
 | 
			
		||||
                               const uint8_t WritePageCommand, const uint8_t PageMode, const uint32_t WriteAddress,
 | 
			
		||||
                               const uint8_t* WriteBuffer, const uint16_t WriteSize)
 | 
			
		||||
{
 | 
			
		||||
	if (PageMode & XPRG_PAGEMODE_ERASE)
 | 
			
		||||
	{
 | 
			
		||||
| 
						 | 
				
			
			@ -285,7 +286,7 @@ bool NVMTarget_WritePageMemory(uint8_t WriteBuffCommand, uint8_t EraseBuffComman
 | 
			
		|||
 *
 | 
			
		||||
 *  \return Boolean true if the command sequence complete successfully
 | 
			
		||||
 */
 | 
			
		||||
bool NVMTarget_EraseMemory(uint8_t EraseCommand, uint32_t Address)
 | 
			
		||||
bool NVMTarget_EraseMemory(const uint8_t EraseCommand, const uint32_t Address)
 | 
			
		||||
{
 | 
			
		||||
	/* Wait until the NVM controller is no longer busy */
 | 
			
		||||
	if (!(NVMTarget_WaitWhileNVMControllerBusy()))
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -106,14 +106,15 @@
 | 
			
		|||
		#define NVM_CMD_READEEPROM             0x06
 | 
			
		||||
 | 
			
		||||
	/* Function Prototypes: */
 | 
			
		||||
		void NVMTarget_SendNVMRegAddress(uint8_t Register);
 | 
			
		||||
		void NVMTarget_SendAddress(uint32_t AbsoluteAddress);
 | 
			
		||||
		void NVMTarget_SendNVMRegAddress(const uint8_t Register);
 | 
			
		||||
		void NVMTarget_SendAddress(const uint32_t AbsoluteAddress);
 | 
			
		||||
		bool NVMTarget_WaitWhileNVMControllerBusy(void);
 | 
			
		||||
		bool NVMTarget_GetMemoryCRC(uint8_t CRCCommand, uint32_t* CRCDest);
 | 
			
		||||
		bool NVMTarget_ReadMemory(uint32_t ReadAddress, uint8_t* ReadBuffer, uint16_t ReadSize);
 | 
			
		||||
		bool NVMTarget_WriteByteMemory(uint8_t WriteCommand, uint32_t WriteAddress, uint8_t* WriteBuffer);
 | 
			
		||||
		bool NVMTarget_WritePageMemory(uint8_t WriteBuffCommand, uint8_t EraseBuffCommand, uint8_t WritePageCommand,
 | 
			
		||||
		                               uint8_t PageMode, uint32_t WriteAddress, uint8_t* WriteBuffer, uint16_t WriteSize);
 | 
			
		||||
		bool NVMTarget_EraseMemory(uint8_t EraseCommand, uint32_t Address);
 | 
			
		||||
		bool NVMTarget_GetMemoryCRC(const uint8_t CRCCommand, uint32_t* const CRCDest);
 | 
			
		||||
		bool NVMTarget_ReadMemory(const uint32_t ReadAddress, uint8_t* ReadBuffer, const uint16_t ReadSize);
 | 
			
		||||
		bool NVMTarget_WriteByteMemory(const uint8_t WriteCommand, const uint32_t WriteAddress, const uint8_t* WriteBuffer);
 | 
			
		||||
		bool NVMTarget_WritePageMemory(const uint8_t WriteBuffCommand, const uint8_t EraseBuffCommand,
 | 
			
		||||
		                               const uint8_t WritePageCommand, const uint8_t PageMode, const uint32_t WriteAddress,
 | 
			
		||||
		                               const uint8_t* WriteBuffer, const uint16_t WriteSize);
 | 
			
		||||
		bool NVMTarget_EraseMemory(const uint8_t EraseCommand, const uint32_t Address);
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -167,7 +167,7 @@ void PDITarget_DisableTargetPDI(void)
 | 
			
		|||
 *
 | 
			
		||||
 *  \param[in] Byte  Byte to send through the USART
 | 
			
		||||
 */
 | 
			
		||||
void PDITarget_SendByte(uint8_t Byte)
 | 
			
		||||
void PDITarget_SendByte(const uint8_t Byte)
 | 
			
		||||
{
 | 
			
		||||
#if defined(PDI_VIA_HARDWARE_USART)
 | 
			
		||||
	/* Switch to Tx mode if currently in Rx mode */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -101,7 +101,7 @@
 | 
			
		|||
	/* Function Prototypes: */
 | 
			
		||||
		void    PDITarget_EnableTargetPDI(void);
 | 
			
		||||
		void    PDITarget_DisableTargetPDI(void);
 | 
			
		||||
		void    PDITarget_SendByte(uint8_t Byte);
 | 
			
		||||
		void    PDITarget_SendByte(const uint8_t Byte);
 | 
			
		||||
		uint8_t PDITarget_ReceiveByte(void);
 | 
			
		||||
		void    PDITarget_SendBreak(void);
 | 
			
		||||
		bool    PDITarget_WaitWhileNVMBusBusy(void);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -120,7 +120,7 @@ void V2Protocol_ProcessCommand(void)
 | 
			
		|||
 *
 | 
			
		||||
 *  \param[in] V2Command  Issued V2 Protocol command byte from the host
 | 
			
		||||
 */
 | 
			
		||||
static void V2Protocol_UnknownCommand(uint8_t V2Command)
 | 
			
		||||
static void V2Protocol_UnknownCommand(const uint8_t V2Command)
 | 
			
		||||
{
 | 
			
		||||
	/* Discard all incoming data */
 | 
			
		||||
	while (Endpoint_BytesInEndpoint() == AVRISP_DATA_EPSIZE)
 | 
			
		||||
| 
						 | 
				
			
			@ -169,7 +169,7 @@ static void V2Protocol_ResetProtection(void)
 | 
			
		|||
 *
 | 
			
		||||
 *  \param[in] V2Command  Issued V2 Protocol command byte from the host
 | 
			
		||||
 */
 | 
			
		||||
static void V2Protocol_GetSetParam(uint8_t V2Command)
 | 
			
		||||
static void V2Protocol_GetSetParam(const uint8_t V2Command)
 | 
			
		||||
{
 | 
			
		||||
	uint8_t ParamID = Endpoint_Read_Byte();
 | 
			
		||||
	uint8_t ParamValue;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -111,7 +111,7 @@ void V2Params_UpdateParamValues(void)
 | 
			
		|||
 *
 | 
			
		||||
 *  \return Privileges for the requested parameter, as a mask of PARAM_PRIV_* masks
 | 
			
		||||
 */ 
 | 
			
		||||
uint8_t V2Params_GetParameterPrivileges(uint8_t ParamID)
 | 
			
		||||
uint8_t V2Params_GetParameterPrivileges(const uint8_t ParamID)
 | 
			
		||||
{
 | 
			
		||||
	ParameterItem_t* ParamInfo = V2Params_GetParamFromTable(ParamID);
 | 
			
		||||
	
 | 
			
		||||
| 
						 | 
				
			
			@ -127,7 +127,7 @@ uint8_t V2Params_GetParameterPrivileges(uint8_t ParamID)
 | 
			
		|||
 *
 | 
			
		||||
 *  \return Current value of the parameter in the table, or 0 if not found
 | 
			
		||||
 */ 
 | 
			
		||||
uint8_t V2Params_GetParameterValue(uint8_t ParamID)
 | 
			
		||||
uint8_t V2Params_GetParameterValue(const uint8_t ParamID)
 | 
			
		||||
{
 | 
			
		||||
	ParameterItem_t* ParamInfo = V2Params_GetParamFromTable(ParamID);
 | 
			
		||||
	
 | 
			
		||||
| 
						 | 
				
			
			@ -144,7 +144,7 @@ uint8_t V2Params_GetParameterValue(uint8_t ParamID)
 | 
			
		|||
 *
 | 
			
		||||
 *  \return Pointer to the associated parameter information from the parameter table if found, NULL otherwise
 | 
			
		||||
 */
 | 
			
		||||
void V2Params_SetParameterValue(uint8_t ParamID, uint8_t Value)
 | 
			
		||||
void V2Params_SetParameterValue(const uint8_t ParamID, const uint8_t Value)
 | 
			
		||||
{
 | 
			
		||||
	ParameterItem_t* ParamInfo = V2Params_GetParamFromTable(ParamID);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -165,7 +165,7 @@ void V2Params_SetParameterValue(uint8_t ParamID, uint8_t Value)
 | 
			
		|||
 *
 | 
			
		||||
 *  \return Pointer to the associated parameter information from the parameter table if found, NULL otherwise
 | 
			
		||||
 */
 | 
			
		||||
static ParameterItem_t* V2Params_GetParamFromTable(uint8_t ParamID)
 | 
			
		||||
static ParameterItem_t* V2Params_GetParamFromTable(const uint8_t ParamID)
 | 
			
		||||
{
 | 
			
		||||
	/* Find the parameter in the parameter table if present */
 | 
			
		||||
	for (uint8_t TableIndex = 0; TableIndex < (sizeof(ParameterTable) / sizeof(ParameterTable[0])); TableIndex++)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -70,12 +70,12 @@
 | 
			
		|||
		void    V2Params_LoadNonVolatileParamValues(void);
 | 
			
		||||
		void    V2Params_UpdateParamValues(void);
 | 
			
		||||
	
 | 
			
		||||
		uint8_t V2Params_GetParameterPrivileges(uint8_t ParamID);
 | 
			
		||||
		uint8_t V2Params_GetParameterValue(uint8_t ParamID);
 | 
			
		||||
		void    V2Params_SetParameterValue(uint8_t ParamID, uint8_t Value);
 | 
			
		||||
		uint8_t V2Params_GetParameterPrivileges(const uint8_t ParamID);
 | 
			
		||||
		uint8_t V2Params_GetParameterValue(const uint8_t ParamID);
 | 
			
		||||
		void    V2Params_SetParameterValue(const uint8_t ParamID, const uint8_t Value);
 | 
			
		||||
		
 | 
			
		||||
		#if defined(INCLUDE_FROM_V2PROTOCOL_PARAMS_C)
 | 
			
		||||
			static ParameterItem_t* V2Params_GetParamFromTable(uint8_t ParamID);
 | 
			
		||||
			static ParameterItem_t* V2Params_GetParamFromTable(const uint8_t ParamID);
 | 
			
		||||
		#endif
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue