A developer I work with found a bug in the TI supplied gpio.c driver, where it returned a uint16_t, instead of the the uint32_t register that it was returning
The bug in the driver has been reported, but I was curious why the compiler did not provide a warning for integer truncation. A warning would have made this issue easy to spot.
Device: TMS320F28069m
Compiler: C2000 TI v6.4.4
Motorware version: 1.01.00.14
File: C:\ti\motorware\motorware_1_01_00_14\sw\drivers\gpio\src\32b\f28x\f2806x\gpio.c
uint16_t GPIO_getPortData(GPIO_Handle gpioHandle, const GPIO_Port_e gpioPort) { GPIO_Obj *gpio = (GPIO_Obj *)gpioHandle; if(gpioPort == GPIO_Port_A) { return (gpio->GPADAT); } else if(gpioPort == GPIO_Port_B) { return (gpio->GPBDAT); } return (NULL); } // end of GPIO_getPortData() function
However...
... volatile uint32_t GPADAT; //!< GPIO A Data Register ...