-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcyutils.c
More file actions
87 lines (72 loc) · 2.57 KB
/
cyutils.c
File metadata and controls
87 lines (72 loc) · 2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*******************************************************************************
* FILENAME: cyutils.c
* Version 4.11
*
* Description:
* CyUtils provides function to handle 24-bit value writes.
*
********************************************************************************
* Copyright 2008-2014, Cypress Semiconductor Corporation. All rights reserved.
* You may use this file only in accordance with the license, terms, conditions,
* disclaimers, and limitations in the end user license agreement accompanying
* the software package with which this file was provided.
*******************************************************************************/
#include "cytypes.h"
#if (!CY_PSOC3)
/***************************************************************************
* Function Name: CySetReg24
****************************************************************************
*
* Summary:
* Writes a 24-bit value to the specified register.
*
* Parameters:
* addr : adress where data must be written
* value: data that must be written
*
* Return:
* None
*
* Reentrant:
* No
*
***************************************************************************/
void CySetReg24(uint32 volatile * addr, uint32 value)
{
uint8 volatile *tmpAddr;
tmpAddr = (uint8 volatile *) addr;
tmpAddr[0u] = (uint8) value;
tmpAddr[1u] = (uint8) (value >> 8u);
tmpAddr[2u] = (uint8) (value >> 16u);
}
#if(CY_PSOC4)
/***************************************************************************
* Function Name: CyGetReg24
****************************************************************************
*
* Summary:
* Reads the 24-bit value from the specified register.
*
* Parameters:
* addr : adress where data must be read
*
* Return:
* None
*
* Reentrant:
* No
*
***************************************************************************/
uint32 CyGetReg24(uint32 const volatile * addr)
{
uint8 const volatile *tmpAddr;
uint32 value;
tmpAddr = (uint8 const volatile *) addr;
value = (uint32) tmpAddr[0u];
value |= ((uint32) tmpAddr[1u] << 8u );
value |= ((uint32) tmpAddr[2u] << 16u);
return(value);
}
#endif /*(CY_PSOC4)*/
#endif /* (!CY_PSOC3) */
/* [] END OF FILE */