예제 #1
0
int i2c_init(i2c_connection conn) {
  struct i2c_state *c = (struct i2c_state *) conn;
  c->base = I2CA0_BASE;
  c->sda_pin_mode = MAP_PinModeGet(c->scl_pin);
  MAP_PinConfigGet(c->sda_pin, &c->sda_pin_strength, &c->sda_pin_type);
  MAP_PinTypeI2C(c->sda_pin, PIN_MODE_1); /* SDA */
  c->scl_pin_mode = MAP_PinModeGet(c->scl_pin);
  MAP_PinConfigGet(c->scl_pin, &c->scl_pin_strength, &c->scl_pin_type);
  MAP_PinTypeI2C(c->scl_pin, PIN_MODE_1); /* SCL */
  MAP_PRCMPeripheralClkEnable(PRCM_I2CA0, PRCM_RUN_MODE_CLK);
  MAP_PRCMPeripheralReset(PRCM_I2CA0);
  MAP_I2CMasterInitExpClk(c->base, SYS_CLK, 0 /* 100 KHz */);
  return 0;
}
예제 #2
0
static void apply_io_park(u8 pin_num, 
                          enum io_park_state park_value)
{
        u32 pin_strength, pin_type;

        if(DONT_CARE != park_value) {
                /* Change the pin mode to GPIO to be safe */
                //MAP_PinModeSet(pin_num, PIN_MODE_0);
            
                /* First apply PullUp/PullDn (or no pull) according 
                to the default levels specified in the user supplied
                parking table */
                MAP_PinConfigGet(pin_num, &pin_strength, &pin_type);

                if(NO_PULL_HIZ != park_value) {
                        MAP_PinConfigSet(pin_num, pin_strength, park_value);
                } else {
                        MAP_PinConfigSet(pin_num, pin_strength, PIN_TYPE_STD);
                }

                /* One by one HiZ all the IOs, 
                  by writing the register that drives IOEN_N control 
                  pin of the IOs. This register and the signal path is 
                  always-on and hence not get lost during True-LPDS */
                MAP_PinDirModeSet(pin_num, PIN_DIR_MODE_IN);

                /* Once all the digital IOs has been made HiZ, 
                  the desired default PAD levels would be held by 
                  the weak-pulls. Input buffers would be alive 
                  (such as auto-SPI or wake-GPIOs) and would not 
                  have Iddq issue since pulls are present. */
        }
        return;
}