Closed
Description
According to the handbook I use a lot of operator= for setting chipselect, reset pins. The code works if I set optimization flag to -O0 or -O1, but sometimes can't work if set to -O2. Take below code as an example:
class ILI9341: public SPI
{
public:
ILI9341(PinName mosi, PinName miso, PinName sclk, PinName cs, PinName reset, PinName dc, PinName backlight);
~ILI9341();
void configureRectangle(uint32_t x1, uint32_t y1, uint32_t x2, uint32_t y2);
private:
DigitalOut cs;
DigitalOut reset;
DigitalOut dc;
};
void ILI9341::configureRectangle(uint32_t x1, uint32_t y1, uint32_t x2, uint32_t y2)
{
cs = 0;
ADDRESS_SET(x1,y1,x2,y2);
dc = 1;
}
The code cs = 0; and dc = 1 in function configureRectangle is optimized if using -O2 as compiler flag.
Is there a way to avoid this problem if I want to use -O2 flag and also the operator= for DigitalOut?
My compiler is arm-none-eabi-gcc version 4.9.3.
Metadata
Metadata
Assignees
Labels
No labels