@ Tesla
Tesla's 90 minute embedded C / firmware coding challenge: 1. Macro for incrementing based on a condition ``` #define INC_COND(COND, VAR) (COND ? (VAR + 1) : VAR) ``` 2. Swap Nibbles in a byte ``` unsigned char swapNibbles(unsigned char x) { unsigned char res = (x & 0x0F) << 4 | (x & 0xF0) >> 4; return res; } ``` 3. Debug ``` uint16_t voltage; // interrupt can modify uint16_t current; // interrupt can modify uint8_t returnPower() { return voltage * current; } ``` a) Volatile declaration needed for variables b) Return variable should be `uint32_t` 4. Memory████████████████████████████████████████████████████████████ █████████████████████████████████████████████████████████████ ██████████████████████████████████████████████████████████████ ███████████████████████████████████████████████████████████████ ████████████████████████████████████████████████████████████████ █████████████████████████████████████████████████████████████████ ██████████████████████████████████████████████████████████████████ ███████████████████████████████████████████████████████████████████ ████████████████████████████████████████████████████████████████████ █████████████████████████████████████████████████████████████████████ ██████████████████████████████████████████████████████████████████████ ███████████████████████████████████████████████████████████████████████ ████████████████████████████████████████████████████████████████████████ █████████████████████████████████████████████████████████████████████████ ██████████████████████████████████████████████████████████████████████████ ███████████████████████████████████████████████████████████████████████████ ████████████████████████████████████████████████████████████████████████████ █████████████████████████████████████████████████████████████████████████████ ██████████████████████████████████████████████████████████████████████████████ ███████████████████████████████████████████████████████████████████████████████ ████████████████████████████████████████████████████████████ █████████████████████████████████████████████████████████████ ██████████████████████████████████████████████████████████████ ███████████████████████████████████████████████████████████████ ████████████████████████████████████████████████████████████████ █████████████████████████████████████████████████████████████████ ██████████████████████████████████████████████████████████████████ ███████████████████████████████████████████████████████████████████ ████████████████████████████████████████████████████████████████████ █████████████████████████████████████████████████████████████████████ ██████████████████████████████████████████████████████████████████████ ███████████████████████████████████████████████████████████████████████ ████████████████████████████████████████████████████████████████████████ █████████████████████████████████████████████████████████████████████████ ██████████████████████████████████████████████████████████████████████████ ███████████████████████████████████████████████████████████████████████████ ████████████████████████████████████████████████████████████████████████████ █████████████████████████████████████████████████████████████████████████████ ██████████████████████████████████████████████████████████████████████████████ ███████████████████████████████████████████████████████████████████████████████ ████████████████████████████████████████████████████████████ █████████████████████████████████████████████████████████████ ██████████████████████████████████████████████████████████████ ███████████████████████████████████████████████████████████████
Company
Tesla
Location
Not specified
Posted
August 9, 2021