<commit_before>#PyFA_GPIO#

###Work in progress, interface may change###

Simple Python based interface for GPIO pins on FriendlyARM boards.

**Limitations:**

* 1kHz seems about the max toggle speed on 400 MHz s3c2451.
* Reaction time fluctuates due to Linux scheduling.

##Install##
You can use the package directly in your project or,

If your system has Python and setuptools, you can use

     python setup.py install

##Functions##
###Init###
* **fgpio.GPIO(Config())**
     * Main gpio class, init with board Config()
* **fgpio.boards.*.Config()**
     * Board specific configuration

###GPIO###
all pins listed in board config are gpio capable.

* **gpio_init(pin, direction, updown)**
     * Initialize pin to use, corrisponds to pinout on GPIO header on board.
     * **pin:** Pin number.
     * **direction:** Input(0) or Output(1).
     * **updown:** Pull Up(2) Down(1) Neither(0), Always 0 for outputs.
* **gpio_close(pin)**
     * Close GPIO enabled pin and set to chip reset values.
* **gpio_close_all()**
     * Close all GPIO enabled pins and set to chip reset values.
* **gpio_write(pin, value)**
     * Write value to pin.
     * **pin:** Pin number.
     * **value:** Value 1 (high) 0 (low)
* **gpio_read(pin)**
     * Read pin value, returns Int 1 (high), 0 (low).
     * **pin:** Pin number.
* **gpio_direction(pin, direction)**
     * Set direction of pin.
     * **pin:** Pin number.
     * **direction:** Input(0) or Output(1).
* **gpio_updown(pin, updown)**
     * Set pull up or pull down on pin (Don't use with pin as output).
     * **pin:** Pin number.
     * **updown:** Pull Up(2) Down(1) Neither(0), Always use 0 for outputs.

###PWM###
board config will show 'pwm' as f2type for pin.

*  **pwm_init(pin, period, duty_cycle)**
     * Initialize pin as PWM.
     * **pin:** Pin number.
     * **period:** Period in nanoseconds.
     * **duty_cycle:** Duty cycel in nanoseconds.
*  **pwm_close(pin)**
     * Close PWM enabled pin, sys/.../unexport.
     * **pin:** Pin number.
*  **pwm_close_all()**
     * Close all PWM enabled pins, sys/.../unexport.
*  **pwm_get_period(pin)**
     * Get period of pin in nanoseconds.
     * **pin:** Pin number.
     * Returns Int
*  **pwm_period(pin, period)**
     * Set period of pin.
     * **period:** Period in nanoseconds.
*  **pwm_get_duty_cycle(pin)**
     * Get duty cycle of pin in nanoseconds.
     * **pin:** Pin number.
     * Returns Int
*  **pwm_duty_cycle(pin, duty_cycle)**
     * Set duty cycle of pin.
     * **pin:** Pin number.<commit_msg>README Fix formatting.<commit_after>#PyFA_GPIO#

###Work in progress, interface may change###

Simple Python based interface for GPIO pins on FriendlyARM boards.

**Limitations:**

* 1kHz seems about the max toggle speed on 400 MHz s3c2451.
* Reaction time fluctuates due to Linux scheduling.

##Install##
You can use the package directly in your project or,

If your system has Python and setuptools, you can use

     python setup.py install

##Functions##
###Init###
* **fgpio.GPIO(Config())**
     * Main gpio class, init with board Config()
* **fgpio.boards.*.Config()**
     * Board specific configuration

###GPIO###
all pins listed in board config are gpio capable.

* **gpio_init(pin, direction, updown)**
     * Initialize pin to use, corrisponds to pinout on GPIO header on board.
     * **pin:** Pin number.
     * **direction:** Input(0) or Output(1).
     * **updown:** Pull Up(2) Down(1) Neither(0), Always 0 for outputs.
* **gpio_close(pin)**
     * Close GPIO enabled pin and set to chip reset values.
* **gpio_close_all()**
     * Close all GPIO enabled pins and set to chip reset values.
* **gpio_write(pin, value)**
     * Write value to pin.
     * **pin:** Pin number.
     * **value:** Value 1 (high) 0 (low)
* **gpio_read(pin)**
     * Read pin value, returns Int 1 (high), 0 (low).
     * **pin:** Pin number.
     * **Returns:** Int
* **gpio_direction(pin, direction)**
     * Set direction of pin.
     * **pin:** Pin number.
     * **direction:** Input(0) or Output(1).
* **gpio_updown(pin, updown)**
     * Set pull up or pull down on pin (Don't use with pin as output).
     * **pin:** Pin number.
     * **updown:** Pull Up(2) Down(1) Neither(0), Always use 0 for outputs.

###PWM###
board config will show 'pwm' as f2type for pin.

*  **pwm_init(pin, period, duty_cycle)**
     * Initialize pin as PWM.
     * **pin:** Pin number.
     * **period:** Period in nanoseconds.
     * **duty_cycle:** Duty cycel in nanoseconds.
*  **pwm_close(pin)**
     * Close PWM enabled pin, sys/.../unexport.
     * **pin:** Pin number.
*  **pwm_close_all()**
     * Close all PWM enabled pins, sys/.../unexport.
*  **pwm_get_period(pin)**
     * Get period of pin in nanoseconds.
     * **pin:** Pin number.
     * **Returns:** Int
*  **pwm_period(pin, period)**
     * Set period of pin.
     * **period:** Period in nanoseconds.
*  **pwm_get_duty_cycle(pin)**
     * Get duty cycle of pin in nanoseconds.
     * **pin:** Pin number.
     * **Returns:** Int
*  **pwm_duty_cycle(pin, duty_cycle)**
     * Set duty cycle of pin.
     * **pin:** Pin number.
{'fraction_non_alphanumeric': 0.15663595373456185, 'fraction_numerical': 0.010194079592236817, 'mean_word_length': 3.168300653594771, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5335567', 'n_tokens_mistral': 1691, 'n_tokens_neox': 1631, 'n_words': 599}