#include <stdio.h> #include <stdint.h> uint32_t set_baud_rate(uint32_t reg, uint8_t baud) { // Your code here //1. Clear bits at position 8-11 (len 4) //1.1 Create a 4 bit mask (1111) and shift into position uint32_t mask = (0x0F << 8); //printf("Reg before: %b\n", reg); reg &= ~mask; //2. Assign baud bits at 8 reg |= baud << 8; return reg; } int main() { uint32_t reg; uint8_t baud; scanf("%u %hhu", ®, &baud); printf("%u", set_baud_rate(reg, baud)); return 0; }
Test Cases
Test Results
Input
0 10
Expected Output
2560