Advertisement
SciresM

MCU v2.0 firmware I2C reg 0x20 handler.

Aug 31st, 2016
385
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.19 KB | None | 0 0
  1. // MCU i2c reg 0x20 handler
  2. sub_4140()
  3. {
  4.     int a = *(reg_0x20);
  5.     *(reg_0x20) = 0;
  6.     if (a & 16)
  7.         *(0xffe23) |= 0x80;
  8.     if (a & 15)
  9.     {
  10.         if (a & 1)
  11.         {
  12.             *(0xff922) = 0;
  13.         }
  14.         else
  15.         {
  16.             if (a & 2)
  17.             {
  18.                 sub_3e8(1, 3, 132); // 1 and 3 on stack. all vals technically have 0x02 as high byte (0x0201, 0x0203, 0x0284)
  19.                 *(0xfff00) &= 0xFD;
  20.                 *(0xfff20) &= 0xFD;
  21.                 *(0xfff03) &= 0xFE;
  22.             }
  23.             if (a & 4)
  24.             {
  25.                 *(0xfff00) &= 0xFD;
  26.                 *(0xfff20) &= 0xFD;
  27.                 if (*0xffc39 == 0)
  28.                     *(0xfff03) &= 0xFE;
  29.                 sub_38ae();
  30.             }
  31.             if (a & 8)
  32.             {
  33.                 *(0xfff03) &= 0xFE;
  34.             }
  35.             sub_2be(5);
  36.             *(0xfff03) |= 1;
  37.             sub_3e8(3, 3, 132);
  38.             *(0xfff20) |= 1;
  39.             sub_2d09();
  40.         }
  41.     }
  42.     return;
  43. }
  44.  
  45. // Wait loop/Watchdog timer setter?
  46. sub_2be(u8 n)
  47. {
  48.     *0xfffab = 0xAC;
  49.     for(u8 i = n ; i > 0; i--)
  50.     {
  51.         for(u16 j = 0x35C; j > 0; j--);
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement