The Code-Bin
Links
Home
Add your code!
All Listings
About
Latest Entry
Featured Scripts
Author's Website
Latest Entries
FFMPEG Thumbnail Scr...
PHP, 0.8KB
Jul. 29, 10:24pm
John
Z80 Assembler, 190 bytes
Feb. 17, 3:36am
John
Z80 Assembler, 176 bytes
Sep. 13, 2:19am
John
Z80 Assembler, 77 bytes
Sep. 13, 2:18am
John
Z80 Assembler, 209 bytes
Sep. 13, 2:17am
untitled C Code
Posted by: julien | July 4, 2008 @ 5:52am
C Code
[
Download
]
void __init at32_select_periph2(unsigned int port, u32 pin_mask, unsigned int periph, unsigned long flags) { int i; int i_a = port == 64 ? 19 : 0; int i_b = port == 64 ? 32 : 19; struct pio_device *pio; for(i = i_a; i < i_b; i++) { unsigned int pin = port + i; unsigned int pin_index = pin & 0x1f; u32 mask = 1 << pin_index; if(!((i << 1) & pin_mask)) continue; pio = gpio_to_pio(pin); if (unlikely(!pio)) { printk("pio: invalid pin %u\n", pin); goto fail; } if (unlikely(test_and_set_bit(pin_index, &pio->pinmux_mask) || gpiochip_is_requested(&pio->chip, pin_index))) { printk("%s: pin %u is busy\n", pio->name, pin_index); goto fail; } pio_writel(pio, PUER, mask); if (periph) pio_writel(pio, BSR, mask); else pio_writel(pio, ASR, mask); pio_writel(pio, PDR, mask); if (!(flags & AT32_GPIOF_PULLUP)) pio_writel(pio, PUDR, mask); } return; fail: dump_stack(); } function call: at32_select_periph(GPIO_PIOC_BASE, data->periph, GPIO_PERIPH_A,0); at32_select_periph(GPIO_PIOD_BASE, data->periph, GPIO_PERIPH_A,0);
Syntax Highlighting
[
Open in new window
]
Author Comments
none
Rating
4.54 / 8
142 Votes
http://codebin.yi.org/169
page generated in 0.01 seconds