Suga Koubou 製 PS_PADライブラリ https://developer.mbed.org/users/okini3939/code/PS_PAD/ を改造したもの。単に__rbitが使えなかったので置き換えただけ。
Dependents: pscontroller project_beta
Fork of PS_PAD by
Diff: PS_PAD.cpp
- Revision:
- 2:14f34d92a797
- Parent:
- 1:840370e1dcce
- Child:
- 3:f5eee5325eed
--- a/PS_PAD.cpp Thu Dec 12 09:04:45 2013 +0000 +++ b/PS_PAD.cpp Sun Mar 19 20:05:17 2017 +0000 @@ -31,7 +31,7 @@ char buf[10]; send(enter_config_mode, 5, buf); - if (buf[2] == 0xff) { + if ((buf[2] == 0xff)||(buf[1] == 0x00)) { return -1; } wait_ms(16); @@ -135,10 +135,20 @@ _cs = 0; wait_us(10); for (i = 0; i < len; i ++) { - dat[i] = __rbit(_spi.write(__rbit(cmd[i] << 24)) << 24); + dat[i] = bitflip32(_spi.write(bitflip32(cmd[i] << 24)) << 24); wait_us(10); } _cs = 1; return i; } +uint32_t PS_PAD::bitflip32(uint32_t x) { + uint32_t r = 0; + int b = 32; + while (b--) { + r <<= 1; + r |= (x & 1); + x >>= 1; + } + return r; +} \ No newline at end of file