Lines Matching defs:pin
34 void mt_set_gpio_dir_chip(uint32_t pin, int dir)
38 assert(pin < MAX_GPIO_PIN);
41 pos = pin / MAX_GPIO_REG_BITS;
42 bit = pin % MAX_GPIO_REG_BITS;
50 int mt_get_gpio_dir_chip(uint32_t pin)
55 assert(pin < MAX_GPIO_PIN);
57 pos = pin / MAX_GPIO_REG_BITS;
58 bit = pin % MAX_GPIO_REG_BITS;
64 void mt_set_gpio_out_chip(uint32_t pin, int output)
68 assert(pin < MAX_GPIO_PIN);
71 pos = pin / MAX_GPIO_REG_BITS;
72 bit = pin % MAX_GPIO_REG_BITS;
80 int mt_get_gpio_out_chip(uint32_t pin)
85 assert(pin < MAX_GPIO_PIN);
87 pos = pin / MAX_GPIO_REG_BITS;
88 bit = pin % MAX_GPIO_REG_BITS;
94 int mt_get_gpio_in_chip(uint32_t pin)
99 assert(pin < MAX_GPIO_PIN);
101 pos = pin / MAX_GPIO_REG_BITS;
102 bit = pin % MAX_GPIO_REG_BITS;
108 void mt_set_gpio_mode_chip(uint32_t pin, int mode)
114 assert(pin < MAX_GPIO_PIN);
120 pos = pin / MAX_GPIO_MODE_PER_REG;
121 bit = (pin % MAX_GPIO_MODE_PER_REG) * GPIO_MODE_BITS;
129 int mt_get_gpio_mode_chip(uint32_t pin)
135 assert(pin < MAX_GPIO_PIN);
139 pos = pin / MAX_GPIO_MODE_PER_REG;
140 bit = (pin % MAX_GPIO_MODE_PER_REG) * GPIO_MODE_BITS;
146 int32_t gpio_get_pull_iocfg(uint32_t pin)
148 switch (pin) {
180 int32_t gpio_get_pupd_iocfg(uint32_t pin)
184 switch (pin) {
198 int gpio_get_pupd_offset(uint32_t pin)
200 switch (pin) {
202 return (pin - 29) * 4 % 32;
204 return (pin - 35) * 4 % 32;
206 return (pin - 91) * 4 % 32;
208 return (pin - 122) * 4 % 32;
210 return (pin - 130) * 4 % 32;
216 void mt_set_gpio_pull_enable_chip(uint32_t pin, int en)
218 int pullen_addr = gpio_get_pull_iocfg(pin) + PULLEN_ADDR_OFFSET;
219 int pupd_addr = gpio_get_pupd_iocfg(pin);
220 int pupd_offset = gpio_get_pupd_offset(pin);
222 assert(pin < MAX_GPIO_PIN);
224 assert(!((PULL_offset[pin].offset == (int8_t)-1) &&
228 if (PULL_offset[pin].offset == (int8_t)-1)
232 1U << PULL_offset[pin].offset);
234 if (PULL_offset[pin].offset == (int8_t)-1) {
246 1U << PULL_offset[pin].offset);
263 int mt_get_gpio_pull_enable_chip(uint32_t pin)
267 int pullen_addr = gpio_get_pull_iocfg(pin) + PULLEN_ADDR_OFFSET;
268 int pupd_addr = gpio_get_pupd_iocfg(pin);
269 int pupd_offset = gpio_get_pupd_offset(pin);
271 assert(pin < MAX_GPIO_PIN);
273 assert(!((PULL_offset[pin].offset == (int8_t)-1) &&
276 if (PULL_offset[pin].offset == (int8_t)-1) {
281 return ((reg & (1U << PULL_offset[pin].offset)) ? 1 : 0);
287 void mt_set_gpio_pull_select_chip(uint32_t pin, int sel)
289 int pullsel_addr = gpio_get_pull_iocfg(pin) + PULLSEL_ADDR_OFFSET;
290 int pupd_addr = gpio_get_pupd_iocfg(pin);
291 int pupd_offset = gpio_get_pupd_offset(pin);
293 assert(pin < MAX_GPIO_PIN);
295 assert(!((PULL_offset[pin].offset == (int8_t) -1) &&
300 mt_set_gpio_pull_enable_chip(pin, GPIO_PULL_DISABLE);
301 if (PULL_offset[pin].offset == (int8_t)-1)
305 1U << PULL_offset[pin].offset);
307 mt_set_gpio_pull_enable_chip(pin, GPIO_PULL_ENABLE);
308 if (PULL_offset[pin].offset == (int8_t)-1)
312 1U << PULL_offset[pin].offset);
314 mt_set_gpio_pull_enable_chip(pin, GPIO_PULL_ENABLE);
315 if (PULL_offset[pin].offset == -1)
319 1U << PULL_offset[pin].offset);
324 int mt_get_gpio_pull_select_chip(uint32_t pin)
328 int pullen_addr = gpio_get_pull_iocfg(pin) + PULLEN_ADDR_OFFSET;
329 int pullsel_addr = gpio_get_pull_iocfg(pin) + PULLSEL_ADDR_OFFSET;
330 int pupd_addr = gpio_get_pupd_iocfg(pin);
331 int pupd_offset = gpio_get_pupd_offset(pin);
333 assert(pin < MAX_GPIO_PIN);
335 assert(!((PULL_offset[pin].offset == (int8_t)-1) &&
338 if (PULL_offset[pin].offset == (int8_t)-1) {
351 if ((reg & (1U << PULL_offset[pin].offset))) {
353 return ((reg & (1U << PULL_offset[pin].offset)) ?
370 uint32_t pin;
372 pin = (uint32_t)gpio;
373 return mt_get_gpio_dir_chip(pin);
378 uint32_t pin;
380 pin = (uint32_t)gpio;
381 mt_set_gpio_pull_select_chip(pin, pull);
386 uint32_t pin;
388 pin = (uint32_t)gpio;
389 return mt_get_gpio_pull_select_chip(pin);
394 uint32_t pin;
396 pin = (uint32_t)gpio;
397 mt_set_gpio_out_chip(pin, value);
402 uint32_t pin;
404 pin = (uint32_t)gpio;
405 return mt_get_gpio_out_chip(pin);
410 uint32_t pin;
412 pin = (uint32_t)gpio;
413 return mt_get_gpio_in_chip(pin);
418 uint32_t pin;
420 pin = (uint32_t)gpio;
421 mt_set_gpio_mode_chip(pin, mode);
426 uint32_t pin;
428 pin = (uint32_t)gpio;
429 return mt_get_gpio_mode_chip(pin);