Revision 1fa17188

View differences:

modules/PowerManagement_1-1/board.c
59 59
                      const uint32_t afrh,
60 60
                      const uint16_t ignmask) {
61 61

  
62
  uint32_t ignmask2 = 0;
63
  uint32_t ignmask4_low = 0;
64
  uint32_t ignmask4_high = 0;
65

  
66
  /* some bit-magic to fan out the mask */
67 62
  const uint8_t lut[] = {0x00, 0x03, 0x0C, 0x0F,
68 63
                         0x30, 0x33, 0x3C, 0x3F,
69 64
                         0xC0, 0xC3, 0xCC, 0xCF,
70 65
                         0xF0, 0xF3, 0xFC, 0xFF};
71
  for (uint8_t i = 0; i < 4; ++i) {
72
    ignmask2 |= lut[(ignmask >> 4*i) & 0x0F] << (8*i);
73
    ignmask4_low |= lut[lut[(ignmask >> 2*i) & 0x03]] << (8*i);
74
    ignmask4_high |= lut[lut[(ignmask >> (8 + 2*i)) & 0x03]] << (8*i);
75
  }
66

  
67
  /* some bit-magic to fan out the mask */
68
  const uint32_t ignmask2 = (lut[(ignmask >> 12)       ] << 24) |
69
                            (lut[(ignmask >>  8) & 0x0F] << 16) |
70
                            (lut[(ignmask >>  4) & 0x0F] <<  8) |
71
                            (lut[(ignmask      ) & 0x0F]);
72
  const uint32_t ignmask4_low = (lut[lut[(ignmask >> 6) & 0x03]] << 24) |
73
                                (lut[lut[(ignmask >> 4) & 0x03]] << 16) |
74
                                (lut[lut[(ignmask >> 2) & 0x03]] <<  8) |
75
                                (lut[lut[(ignmask     ) & 0x03]]);
76
  const uint32_t ignmask4_high = (lut[lut[(ignmask >> 14)       ]] << 24) |
77
                                 (lut[lut[(ignmask >> 12) & 0x03]] << 16) |
78
                                 (lut[lut[(ignmask >> 10) & 0x03]] <<  8) |
79
                                 (lut[lut[(ignmask >>  8) & 0x03]]);
76 80

  
77 81
  gpiop->OTYPER  = (gpiop->OTYPER  & ignmask      ) | (otyper  & ~ignmask      );
78 82
  gpiop->OSPEEDR = (gpiop->OSPEEDR & ignmask2     ) | (ospeedr & ~ignmask2     );

Also available in: Unified diff