Data Types
Standard Data Types
Note: The pre-defined variable types that come with the PSoC programming suites are defined both with and without the _t suffix that most people use to define a typedef (e.g. uint8_t). I recommend using the version with the underscore, as this increases portability (this is also supported by Linux and other Unix-like systems). It is better practice to use the data types whose size is explicitly stated (e.g. uint32_t rather than unsigned int as the latter’s size is platform-dependant). The following data types are valid for all PSoC families.
// Standard C data types (implicit sizes)charshortintlongfloatdouble
// Types available through <stdint.h>int8_tuint8_tint16_tuint16_tint32_tuint32_tint64_tuint64_tsize_t
// Cypress-defined data types (explicit sizes)// Note that 64-bit data types are only availiable// with the _t suffixint8uint8int16uint16int32uint32Standard C Variable Type Sizes On PSoC 5
| Data Type | Size (bytes) | Range | Decimal Precision (places) | printf() identifier |
|---|---|---|---|---|
| char | 1 | 0-255 | %c | |
| short | 2 | %i | ||
| int | 4 | %i | ||
| unsigned int | 4 | %u | ||
| long | 4 | %i | ||
| float | 4 | 7 | %f | |
| double | 8 | 15 | %f |
These were discovered using the sizeof() command, and printing the result to a debug terminal.