Lesson KB 03: Data Types and APIs
The PSoC Creator provides some useful APIs that can be used in your code.
- Standard C data types (implicit sizes)
Type Size
(Bytes)Range Description Precision
(Decimal place)printf() identifier char 1 unsigned: 0 ... 255
signed: -128 ... 127Character (ASCII Table) %c short 2 unsigned: 0 ... 65535
signed:-32,768 ... 32767Standard type specifying 2-byte integers %i int 4 unsigned: 0 ... 4,294,967,295
signed:-2,147,483,648 ... 2,147,483,647Integer number %i long 4 unsigned: 0 ... 4,294,967,295
signed:-2,147,483,648 ... 2,147,483,647%i float 4 1.175e-38 ... 3.40e+38 Signal precision floating point number 6 %f double 8 2.3E-308 ... 1.7E+308 Double precision floating point number 15 %f long double 8 2.3E-308 ... 1.7E+308 %f enum 1
21 byte if enum < 256
2 bytes if enum > 256 0 ... 65535Used to define a list of aliases that represent integers - Cypress-defined data types
Type Description char8 8-bit (signed or unsigned, depending on the compiler selection for char) uint8 8-bit unsigned integer uint16 16-bit unsigned integer uint32 32-bit unsigned integer int8 8-bit signed integer int16 16-bit signed integer int32 32-bit signed integer float32 32-bit float float64 64-bit float int64 64-bit signed uint64 64-bit unsigned - Cypress-defined hardware register types
Type Description reg8 Volatile 8-bit unsigned reg16 Volatile 16-bit unsigned reg32 Volatile 32-bit unsigned - Types available through <stdint.h>
Type Description uint8_t 8-bit unsigned integer uint16_t 16-bit unsigned integer uint32_t 32-bit unsigned integer uint64_t 64-bit unsigned integer int8_t 8-bit signed integer int16_t 16-bit signed integer int32_t 32-bit signed integer int64_t 64-bit signed integer - Delay Functions
Function Prototype Arguments Description void CyDelay(uint32 milliseconds) uint32 milliseconds –
Number of milliseconds to delayDelay by the specified number of milliseconds. Ex. To delay 2.5 second → CyDelay(2500); void CyDelayUs(uint32 microseconds) uint32 microseconds –
Number of microseconds to delayDelay by the specified number of microseconds. Ex. To delay 500 microsecond → CyDelayUs(500); void CyDelayFreq(uint32 freq) uint32 freq –
Bus clock frequency in Hz;
0: Use default value
Nonzero: Set freq valueSets the Bus Clock frequency to calculate the number of cycles needed to implement a delay with CyDelay or CyDelayUs functions.
By default, the frequency used is based on the value determined by PSoC Creator at build time.void CyDelayCycles(uint32 cycles) uint32 cycles –
Number of cycles to delay (0 ~ 32)Delay by the specified number of cycles using a software delay loop. - Macro statements
CyGlobalIntEnable Enables interrupts using the global interrupt mask CyGlobalIntDisable Disable interrupts using the global interrupt mask
Here, lists some useful defines: