commit
0084f0af24
|
@ -0,0 +1,446 @@
|
|||
name: Build CI
|
||||
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
release:
|
||||
types: [published]
|
||||
check_suite:
|
||||
types: [rerequested]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-18.04
|
||||
steps:
|
||||
- name: Dump GitHub context
|
||||
env:
|
||||
GITHUB_CONTEXT: ${{ toJson(github) }}
|
||||
run: echo "$GITHUB_CONTEXT"
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: true
|
||||
fetch-depth: 0
|
||||
- run: git fetch --recurse-submodules=no https://github.com/adafruit/circuitpython refs/tags/*:refs/tags/*
|
||||
- run: git submodule sync
|
||||
- run: git submodule foreach git remote -v
|
||||
- run: git submodule foreach git fetch --recurse-submodules=no origin +refs/tags/*:refs/tags/*
|
||||
- name: CircuitPython version
|
||||
run: git describe --dirty --tags
|
||||
- name: Set up Python 3.8
|
||||
uses: actions/setup-python@v1
|
||||
with:
|
||||
python-version: 3.8
|
||||
- name: Install deps
|
||||
run: |
|
||||
sudo apt-get install -y eatmydata
|
||||
sudo eatmydata apt-get install -y gettext librsvg2-bin mingw-w64
|
||||
pip install requests sh click setuptools cpp-coveralls "Sphinx<4" sphinx-rtd-theme recommonmark sphinx-autoapi sphinxcontrib-svg2pdfconverter polib pyyaml astroid
|
||||
- name: Versions
|
||||
run: |
|
||||
gcc --version
|
||||
python3 --version
|
||||
- name: Build mpy-cross
|
||||
run: make -C mpy-cross -j2
|
||||
- name: Build unix port
|
||||
run: |
|
||||
make -C ports/unix deplibs -j2
|
||||
make -C ports/unix -j2
|
||||
make -C ports/unix coverage -j2
|
||||
- name: Test all
|
||||
run: MICROPY_CPYTHON3=python3.8 MICROPY_MICROPYTHON=../ports/unix/micropython_coverage ./run-tests -j1
|
||||
working-directory: tests
|
||||
- name: Print failure info
|
||||
run: |
|
||||
for exp in *.exp;
|
||||
do testbase=$(basename $exp .exp);
|
||||
echo -e "\nFAILURE $testbase";
|
||||
diff -u $testbase.exp $testbase.out;
|
||||
done
|
||||
working-directory: tests
|
||||
if: failure()
|
||||
- name: Native Tests
|
||||
run: MICROPY_CPYTHON3=python3.8 MICROPY_MICROPYTHON=../ports/unix/micropython_coverage ./run-tests -j1 --emit native
|
||||
working-directory: tests
|
||||
- name: mpy Tests
|
||||
run: MICROPY_CPYTHON3=python3.8 MICROPY_MICROPYTHON=../ports/unix/micropython_coverage ./run-tests -j1 --via-mpy -d basics float
|
||||
working-directory: tests
|
||||
- name: Stubs
|
||||
run: make stubs -j2
|
||||
- name: Docs
|
||||
run: sphinx-build -E -W -b html . _build/html
|
||||
- name: Translations
|
||||
run: make check-translate
|
||||
- name: New boards check
|
||||
run: python3 -u ci_new_boards_check.py
|
||||
working-directory: tools
|
||||
- name: Build mpy-cross.static-raspbian
|
||||
run: make -C mpy-cross -j2 -f Makefile.static-raspbian
|
||||
- uses: actions/upload-artifact@v1.0.0
|
||||
with:
|
||||
name: mpy-cross.static-raspbian
|
||||
path: mpy-cross/mpy-cross.static-raspbian
|
||||
|
||||
- name: Build mpy-cross.static
|
||||
run: make -C mpy-cross -j2 -f Makefile.static
|
||||
- uses: actions/upload-artifact@v1.0.0
|
||||
with:
|
||||
name: mpy-cross.static-amd64-linux
|
||||
path: mpy-cross/mpy-cross.static
|
||||
|
||||
- name: Build mpy-cross.static-mingw
|
||||
run: make -C mpy-cross -j2 -f Makefile.static-mingw
|
||||
- uses: actions/upload-artifact@v1.0.0
|
||||
with:
|
||||
name: mpy-cross.static-x64-windows
|
||||
path: mpy-cross/mpy-cross.static.exe
|
||||
|
||||
mpy-cross-mac:
|
||||
runs-on: macos-10.15
|
||||
steps:
|
||||
- name: Dump GitHub context
|
||||
env:
|
||||
GITHUB_CONTEXT: ${{ toJson(github) }}
|
||||
run: echo "$GITHUB_CONTEXT"
|
||||
- name: Make gettext programs available
|
||||
run: |
|
||||
brew install gettext
|
||||
echo "::set-env name=PATH::/usr/local/opt/gettext/bin:$PATH"
|
||||
- name: Versions
|
||||
run: |
|
||||
gcc --version
|
||||
python3 --version
|
||||
msgfmt --version
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: true
|
||||
fetch-depth: 0
|
||||
- run: git fetch --recurse-submodules=no https://github.com/adafruit/circuitpython refs/tags/*:refs/tags/*
|
||||
- run: git submodule sync
|
||||
- run: git submodule foreach git remote -v
|
||||
- run: git submodule foreach git fetch --recurse-submodules=no origin +refs/tags/*:refs/tags/*
|
||||
- name: CircuitPython version
|
||||
run: git describe --dirty --tags
|
||||
- name: Build mpy-cross
|
||||
run: make -C mpy-cross -j2
|
||||
- uses: actions/upload-artifact@v1.0.0
|
||||
with:
|
||||
name: mpy-cross-macos-catalina
|
||||
path: mpy-cross/mpy-cross
|
||||
|
||||
build-arm:
|
||||
runs-on: ubuntu-18.04
|
||||
needs: test
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
board:
|
||||
- "8086_commander"
|
||||
- "TG-Watch02A"
|
||||
- "aloriumtech_evo_m51"
|
||||
- "aramcon_badge_2019"
|
||||
- "arduino_mkr1300"
|
||||
- "arduino_mkrzero"
|
||||
- "arduino_nano_33_ble"
|
||||
- "arduino_nano_33_iot"
|
||||
- "arduino_zero"
|
||||
- "bast_pro_mini_m0"
|
||||
- "bdmicro_vina_m0"
|
||||
- "capablerobot_usbhub"
|
||||
- "catwan_usbstick"
|
||||
- "circuitbrains_basic_m0"
|
||||
- "circuitbrains_deluxe_m4"
|
||||
- "circuitplayground_bluefruit"
|
||||
- "circuitplayground_express"
|
||||
- "circuitplayground_express_crickit"
|
||||
- "circuitplayground_express_displayio"
|
||||
- "clue_nrf52840_express"
|
||||
- "cp32-m4"
|
||||
- "datalore_ip_m4"
|
||||
- "datum_distance"
|
||||
- "datum_imu"
|
||||
- "datum_light"
|
||||
- "datum_weather"
|
||||
- "electronut_labs_blip"
|
||||
- "electronut_labs_papyr"
|
||||
- "escornabot_makech"
|
||||
- "espruino_pico"
|
||||
- "espruino_wifi"
|
||||
- "feather_bluefruit_sense"
|
||||
- "feather_m0_adalogger"
|
||||
- "feather_m0_basic"
|
||||
- "feather_m0_express"
|
||||
- "feather_m0_express_crickit"
|
||||
- "feather_m0_rfm69"
|
||||
- "feather_m0_rfm9x"
|
||||
- "feather_m0_supersized"
|
||||
- "feather_m4_express"
|
||||
- "feather_m7_1011"
|
||||
- "feather_mimxrt1011"
|
||||
- "feather_mimxrt1062"
|
||||
- "feather_nrf52840_express"
|
||||
- "feather_radiofruit_zigbee"
|
||||
- "feather_stm32f405_express"
|
||||
- "fluff_m0"
|
||||
- "gemma_m0"
|
||||
- "grandcentral_m4_express"
|
||||
- "hallowing_m0_express"
|
||||
- "hallowing_m4_express"
|
||||
- "hiibot_bluefi"
|
||||
- "imxrt1010_evk"
|
||||
- "imxrt1020_evk"
|
||||
- "imxrt1060_evk"
|
||||
- "itsybitsy_m0_express"
|
||||
- "itsybitsy_m4_express"
|
||||
- "itsybitsy_nrf52840_express"
|
||||
- "kicksat-sprite"
|
||||
- "makerdiary_nrf52840_mdk"
|
||||
- "makerdiary_nrf52840_mdk_usb_dongle"
|
||||
- "meowbit_v121"
|
||||
- "meowmeow"
|
||||
- "metro_m0_express"
|
||||
- "metro_m4_airlift_lite"
|
||||
- "metro_m4_express"
|
||||
- "metro_nrf52840_express"
|
||||
- "mini_sam_m4"
|
||||
- "monster_m4sk"
|
||||
- "ndgarage_ndbit6"
|
||||
- "nfc_copy_cat"
|
||||
- "nice_nano"
|
||||
- "nucleo_f746zg"
|
||||
- "nucleo_f767zi"
|
||||
- "nucleo_h743zi_2"
|
||||
- "ohs2020_badge"
|
||||
- "openbook_m4"
|
||||
- "openmv_h7"
|
||||
- "particle_argon"
|
||||
- "particle_boron"
|
||||
- "particle_xenon"
|
||||
- "pca10056"
|
||||
- "pca10059"
|
||||
- "pca10100"
|
||||
- "pewpew10"
|
||||
- "pewpew_m4"
|
||||
- "pirkey_m0"
|
||||
- "pitaya_go"
|
||||
- "pyb_nano_v2"
|
||||
- "pybadge"
|
||||
- "pybadge_airlift"
|
||||
- "pyboard_v11"
|
||||
- "pycubed"
|
||||
- "pycubed_mram"
|
||||
- "pygamer"
|
||||
- "pygamer_advance"
|
||||
- "pyportal"
|
||||
- "pyportal_titano"
|
||||
- "pyruler"
|
||||
- "robohatmm1_m4"
|
||||
- "sam32"
|
||||
- "seeeduino_xiao"
|
||||
- "serpente"
|
||||
- "shirtty"
|
||||
- "simmel"
|
||||
- "snekboard"
|
||||
- "sparkfun_lumidrive"
|
||||
- "sparkfun_nrf52840_mini"
|
||||
- "sparkfun_qwiic_micro_no_flash"
|
||||
- "sparkfun_qwiic_micro_with_flash"
|
||||
- "sparkfun_redboard_turbo"
|
||||
- "sparkfun_samd21_dev"
|
||||
- "sparkfun_samd21_mini"
|
||||
- "sparkfun_samd51_thing_plus"
|
||||
- "spresense"
|
||||
- "stm32f411ce_blackpill"
|
||||
- "stm32f411ve_discovery"
|
||||
- "stm32f412zg_discovery"
|
||||
- "stm32f4_discovery"
|
||||
- "stm32f746g_discovery"
|
||||
- "stringcar_m0_express"
|
||||
- "teensy40"
|
||||
- "teensy41"
|
||||
- "teknikio_bluebird"
|
||||
- "thunderpack"
|
||||
- "trellis_m4_express"
|
||||
- "trinket_m0"
|
||||
- "trinket_m0_haxpress"
|
||||
- "uartlogger2"
|
||||
- "uchip"
|
||||
- "ugame10"
|
||||
- "winterbloom_big_honking_button"
|
||||
- "winterbloom_sol"
|
||||
- "xinabox_cc03"
|
||||
- "xinabox_cs11"
|
||||
|
||||
steps:
|
||||
- name: Set up Python 3.8
|
||||
uses: actions/setup-python@v1
|
||||
with:
|
||||
python-version: 3.8
|
||||
- name: Install deps
|
||||
run: |
|
||||
sudo apt-get install -y gettext
|
||||
pip install requests sh click setuptools awscli
|
||||
wget https://adafruit-circuit-python.s3.amazonaws.com/gcc-arm-none-eabi-9-2019-q4-major-x86_64-linux.tar.bz2
|
||||
sudo tar -C /usr --strip-components=1 -xaf gcc-arm-none-eabi-9-2019-q4-major-x86_64-linux.tar.bz2
|
||||
- name: Versions
|
||||
run: |
|
||||
gcc --version
|
||||
arm-none-eabi-gcc --version
|
||||
python3 --version
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: true
|
||||
fetch-depth: 0
|
||||
- run: git fetch --recurse-submodules=no https://github.com/adafruit/circuitpython refs/tags/*:refs/tags/*
|
||||
- run: git submodule sync
|
||||
- run: git submodule foreach git remote -v
|
||||
- run: git submodule foreach git fetch --recurse-submodules=no origin +refs/tags/*:refs/tags/*
|
||||
- name: mpy-cross
|
||||
run: make -C mpy-cross -j2
|
||||
- name: build
|
||||
run: python3 -u build_release_files.py
|
||||
working-directory: tools
|
||||
env:
|
||||
BOARDS: ${{ matrix.board }}
|
||||
- uses: actions/upload-artifact@v1.0.0
|
||||
with:
|
||||
name: ${{ matrix.board }}
|
||||
path: bin/${{ matrix.board }}
|
||||
- name: Upload to S3
|
||||
run: "[ -z \"$AWS_ACCESS_KEY_ID\" ] || aws s3 cp bin/ s3://adafruit-circuit-python/bin/ --recursive --no-progress --region us-east-1"
|
||||
env:
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
if: github.event_name == 'push' || (github.event_name == 'release' && (github.event.action == 'published' || github.event.action == 'rerequested'))
|
||||
|
||||
build-riscv:
|
||||
runs-on: ubuntu-18.04
|
||||
needs: test
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
board:
|
||||
- "fomu"
|
||||
|
||||
steps:
|
||||
- name: Set up Python 3.8
|
||||
uses: actions/setup-python@v1
|
||||
with:
|
||||
python-version: 3.8
|
||||
- name: Install deps
|
||||
run: |
|
||||
sudo apt-get install -y gettext
|
||||
pip install requests sh click setuptools awscli
|
||||
wget https://static.dev.sifive.com/dev-tools/riscv64-unknown-elf-gcc-8.3.0-2019.08.0-x86_64-linux-centos6.tar.gz
|
||||
sudo tar -C /usr --strip-components=1 -xaf riscv64-unknown-elf-gcc-8.3.0-2019.08.0-x86_64-linux-centos6.tar.gz
|
||||
- name: Versions
|
||||
run: |
|
||||
gcc --version
|
||||
riscv64-unknown-elf-gcc --version
|
||||
python3 --version
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: true
|
||||
fetch-depth: 0
|
||||
- run: git fetch --recurse-submodules=no https://github.com/adafruit/circuitpython refs/tags/*:refs/tags/*
|
||||
- run: git submodule sync
|
||||
- run: git submodule foreach git remote -v
|
||||
- run: git submodule foreach git fetch --recurse-submodules=no origin +refs/tags/*:refs/tags/*
|
||||
- name: mpy-cross
|
||||
run: make -C mpy-cross -j2
|
||||
- name: build
|
||||
run: python3 -u build_release_files.py
|
||||
working-directory: tools
|
||||
env:
|
||||
BOARDS: ${{ matrix.board }}
|
||||
- uses: actions/upload-artifact@v1.0.0
|
||||
with:
|
||||
name: ${{ matrix.board }}
|
||||
path: bin/${{ matrix.board }}
|
||||
- name: Upload to S3
|
||||
run: "[ -z \"$AWS_ACCESS_KEY_ID\" ] || aws s3 cp bin/ s3://adafruit-circuit-python/bin/ --recursive --no-progress --region us-east-1"
|
||||
env:
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
if: github.event_name == 'push' || (github.event_name == 'release' && (github.event.action == 'published' || github.event.action == 'rerequested'))
|
||||
build-xtensa:
|
||||
runs-on: ubuntu-latest
|
||||
needs: test
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
board:
|
||||
- "espressif_saola_1_wroom"
|
||||
- "espressif_saola_1_wrover"
|
||||
|
||||
steps:
|
||||
- name: Set up Python 3.8
|
||||
uses: actions/setup-python@v1
|
||||
with:
|
||||
python-version: 3.8
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: true
|
||||
fetch-depth: 0
|
||||
- run: git fetch --recurse-submodules=no https://github.com/adafruit/circuitpython refs/tags/*:refs/tags/*
|
||||
- run: git submodule sync
|
||||
- run: git submodule foreach git remote -v
|
||||
- run: git submodule foreach git fetch --recurse-submodules=no origin +refs/tags/*:refs/tags/*
|
||||
- name: CircuitPython version
|
||||
run: git describe --dirty --tags
|
||||
- uses: actions/cache@v1
|
||||
name: Fetch IDF tool cache
|
||||
id: idf-cache
|
||||
with:
|
||||
path: ${{ github.workspace }}/.idf_tools
|
||||
key: ${{ runner.os }}-idf-tools-${{ hashFiles('.git/modules/ports/esp32s2/esp-idf/HEAD') }}-20200523
|
||||
- name: Install IDF tools
|
||||
run: |
|
||||
$IDF_PATH/tools/idf_tools.py --non-interactive install required
|
||||
$IDF_PATH/tools/idf_tools.py --non-interactive install cmake
|
||||
$IDF_PATH/tools/idf_tools.py --non-interactive install-python-env
|
||||
rm -rf $IDF_TOOLS_PATH/dist
|
||||
env:
|
||||
IDF_PATH: ${{ github.workspace }}/ports/esp32s2/esp-idf
|
||||
IDF_TOOLS_PATH: ${{ github.workspace }}/.idf_tools
|
||||
- name: Install CircuitPython deps
|
||||
run: |
|
||||
source $IDF_PATH/export.sh
|
||||
pip install requests sh click setuptools awscli
|
||||
sudo apt-get install -y gettext ninja-build
|
||||
env:
|
||||
IDF_PATH: ${{ github.workspace }}/ports/esp32s2/esp-idf
|
||||
IDF_TOOLS_PATH: ${{ github.workspace }}/.idf_tools
|
||||
- name: Versions
|
||||
run: |
|
||||
source $IDF_PATH/export.sh
|
||||
gcc --version
|
||||
xtensa-esp32s2-elf-gcc --version
|
||||
python3 --version
|
||||
ninja --version
|
||||
cmake --version
|
||||
shell: bash
|
||||
env:
|
||||
IDF_PATH: ${{ github.workspace }}/ports/esp32s2/esp-idf
|
||||
IDF_TOOLS_PATH: ${{ github.workspace }}/.idf_tools
|
||||
- name: mpy-cross
|
||||
run: make -C mpy-cross -j2
|
||||
- name: build
|
||||
run: |
|
||||
source $IDF_PATH/export.sh
|
||||
python3 -u build_release_files.py
|
||||
working-directory: tools
|
||||
shell: bash
|
||||
env:
|
||||
IDF_PATH: ${{ github.workspace }}/ports/esp32s2/esp-idf
|
||||
IDF_TOOLS_PATH: ${{ github.workspace }}/.idf_tools
|
||||
BOARDS: ${{ matrix.board }}
|
||||
- uses: actions/upload-artifact@v1.0.0
|
||||
with:
|
||||
name: ${{ matrix.board }}
|
||||
path: bin/${{ matrix.board }}
|
||||
- name: Upload to S3
|
||||
run: "[ -z \"$AWS_ACCESS_KEY_ID\" ] || aws s3 cp bin/ s3://adafruit-circuit-python/bin/ --recursive --no-progress --region us-east-1"
|
||||
env:
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
if: github.event_name == 'push' || (github.event_name == 'release' && (github.event.action == 'published' || github.event.action == 'rerequested'))
|
|
@ -0,0 +1,40 @@
|
|||
name: Update CircuitPython.org
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
|
||||
jobs:
|
||||
website:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Dump GitHub context
|
||||
env:
|
||||
GITHUB_CONTEXT: ${{ toJson(github) }}
|
||||
run: echo "$GITHUB_CONTEXT"
|
||||
- name: Set up Python 3.8
|
||||
uses: actions/setup-python@v1
|
||||
with:
|
||||
python-version: 3.8
|
||||
- name: Install deps
|
||||
run: |
|
||||
pip install requests sh click
|
||||
- name: Versions
|
||||
run: |
|
||||
gcc --version
|
||||
python3 --version
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: true
|
||||
fetch-depth: 0
|
||||
- run: git fetch --recurse-submodules=no https://github.com/adafruit/circuitpython refs/tags/*:refs/tags/*
|
||||
- run: git submodule foreach git fetch --recurse-submodules=no origin +refs/tags/*:refs/tags/*
|
||||
- name: CircuitPython version
|
||||
run: git describe --dirty --tags
|
||||
- name: Website
|
||||
run: python3 build_board_info.py
|
||||
working-directory: tools
|
||||
env:
|
||||
RELEASE_TAG: ${{ github.event.release.tag_name }}
|
||||
ADABOT_GITHUB_ACCESS_TOKEN: ${{ secrets.BLINKA_GITHUB_ACCESS_TOKEN }}
|
||||
if: github.event_name == 'release' && (github.event.action == 'published' || github.event.action == 'rerequested')
|
|
@ -0,0 +1,24 @@
|
|||
# SPDX-FileCopyrightText: Copyright (c) 2019 Anthony Sottile
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
name: pre-commit
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches: [master]
|
||||
|
||||
jobs:
|
||||
pre-commit:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- uses: actions/setup-python@v1
|
||||
- name: set PY
|
||||
run: echo "::set-env name=PY::$(python -c 'import hashlib, sys;print(hashlib.sha256(sys.version.encode()+sys.executable.encode()).hexdigest())')"
|
||||
- uses: actions/cache@v1
|
||||
with:
|
||||
path: ~/.cache/pre-commit
|
||||
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
|
||||
- uses: pre-commit/action@v1.1.0
|
|
@ -12,6 +12,9 @@
|
|||
|
||||
# Packages
|
||||
############
|
||||
dist/
|
||||
*.egg-info
|
||||
.eggs
|
||||
|
||||
# Logs and Databases
|
||||
######################
|
||||
|
@ -25,6 +28,7 @@
|
|||
######################
|
||||
build/
|
||||
bin/
|
||||
circuitpython-stubs/
|
||||
|
||||
# Test failure outputs
|
||||
######################
|
||||
|
@ -48,6 +52,7 @@ _build
|
|||
# Generated rst files
|
||||
######################
|
||||
genrst/
|
||||
/autoapi/
|
||||
|
||||
# ctags and similar
|
||||
###################
|
||||
|
@ -62,7 +67,11 @@ TAGS
|
|||
*~
|
||||
|
||||
*.DS_Store
|
||||
**/*.DS_Store
|
||||
*.icloud
|
||||
|
||||
# POEdit mo files
|
||||
####################
|
||||
*.mo
|
||||
|
||||
.vscode
|
||||
|
|
|
@ -5,9 +5,6 @@
|
|||
[submodule "lib/libffi"]
|
||||
path = lib/libffi
|
||||
url = https://github.com/atgreen/libffi
|
||||
[submodule "lib/lwip"]
|
||||
path = lib/lwip
|
||||
url = https://git.savannah.gnu.org/r/lwip.git
|
||||
[submodule "lib/berkeley-db-1.xx"]
|
||||
path = lib/berkeley-db-1.xx
|
||||
url = https://github.com/pfalcon/berkeley-db-1.xx
|
||||
|
@ -32,10 +29,6 @@
|
|||
[submodule "tools/python-semver"]
|
||||
path = tools/python-semver
|
||||
url = https://github.com/k-bx/python-semver.git
|
||||
[submodule "lib/stm32lib"]
|
||||
path = lib/stm32lib
|
||||
url = https://github.com/micropython/stm32lib
|
||||
branch = work-F4-1.13.1+F7-1.5.0+L4-1.3.0
|
||||
[submodule "atmel-samd/asf4"]
|
||||
path = ports/atmel-samd/asf4
|
||||
url = https://github.com/adafruit/asf4.git
|
||||
|
@ -78,11 +71,75 @@
|
|||
url = https://github.com/adafruit/nrfx.git
|
||||
[submodule "lib/tinyusb"]
|
||||
path = lib/tinyusb
|
||||
url = https://github.com/tannewt/tinyusb.git
|
||||
branch = develop
|
||||
url = https://github.com/hathach/tinyusb.git
|
||||
branch = master
|
||||
fetchRecurseSubmodules = false
|
||||
[submodule "tools/huffman"]
|
||||
path = tools/huffman
|
||||
url = https://github.com/tannewt/huffman.git
|
||||
[submodule "tools/adabot"]
|
||||
path = tools/adabot
|
||||
url = https://github.com/adafruit/adabot.git
|
||||
[submodule "tools/bitmap_font"]
|
||||
path = tools/bitmap_font
|
||||
url = https://github.com/adafruit/Adafruit_CircuitPython_BitmapFont.git
|
||||
[submodule "tools/Tecate-bitmap-fonts"]
|
||||
path = tools/Tecate-bitmap-fonts
|
||||
url = https://github.com/Tecate/bitmap-fonts.git
|
||||
[submodule "frozen/pew-pewpew-standalone-10.x"]
|
||||
path = frozen/pew-pewpew-standalone-10.x
|
||||
url = https://github.com/pewpew-game/pew-pewpew-standalone-10.x.git
|
||||
[submodule "frozen/circuitpython-stage"]
|
||||
path = frozen/circuitpython-stage
|
||||
url = https://github.com/python-ugame/circuitpython-stage.git
|
||||
[submodule "ports/cxd56/spresense-exported-sdk"]
|
||||
path = ports/cxd56/spresense-exported-sdk
|
||||
url = https://github.com/sonydevworld/spresense-exported-sdk.git
|
||||
[submodule "frozen/Adafruit_CircuitPython_SD"]
|
||||
path = frozen/Adafruit_CircuitPython_SD
|
||||
url = https://github.com/adafruit/Adafruit_CircuitPython_SD.git
|
||||
[submodule "lib/mp3"]
|
||||
path = lib/mp3
|
||||
url = https://github.com/adafruit/Adafruit_MP3
|
||||
[submodule "ports/mimxrt10xx/sdk"]
|
||||
path = ports/mimxrt10xx/sdk
|
||||
url = https://github.com/adafruit/MIMXRT10xx_SDK
|
||||
[submodule "frozen/Adafruit_CircuitPython_Register"]
|
||||
path = frozen/Adafruit_CircuitPython_Register
|
||||
url = https://github.com/adafruit/Adafruit_CircuitPython_Register.git
|
||||
[submodule "extmod/ulab"]
|
||||
path = extmod/ulab
|
||||
url = https://github.com/v923z/micropython-ulab
|
||||
[submodule "frozen/Adafruit_CircuitPython_ESP32SPI"]
|
||||
path = frozen/Adafruit_CircuitPython_ESP32SPI
|
||||
url = https://github.com/adafruit/Adafruit_CircuitPython_ESP32SPI
|
||||
[submodule "frozen/Adafruit_CircuitPython_Requests"]
|
||||
path = frozen/Adafruit_CircuitPython_Requests
|
||||
url = https://github.com/adafruit/Adafruit_CircuitPython_Requests
|
||||
[submodule "ports/stm/st_driver"]
|
||||
path = ports/stm/st_driver
|
||||
url = https://github.com/hathach/st_driver.git
|
||||
[submodule "lib/protomatter"]
|
||||
path = lib/protomatter
|
||||
url = https://github.com/adafruit/Adafruit_Protomatter
|
||||
[submodule "frozen/Adafruit_CircuitPython_LSM6DS"]
|
||||
path = frozen/Adafruit_CircuitPython_LSM6DS
|
||||
url = https://github.com/adafruit/Adafruit_CircuitPython_LSM6DS
|
||||
[submodule "frozen/Adafruit_CircuitPython_FocalTouch"]
|
||||
path = frozen/Adafruit_CircuitPython_FocalTouch
|
||||
url = https://github.com/adafruit/Adafruit_CircuitPython_FocalTouch
|
||||
[submodule "frozen/Adafruit_CircuitPython_DS3231"]
|
||||
path = frozen/Adafruit_CircuitPython_DS3231
|
||||
url = https://github.com/adafruit/Adafruit_CircuitPython_DS3231
|
||||
[submodule "frozen/Adafruit_CircuitPython_DRV2605"]
|
||||
path = frozen/Adafruit_CircuitPython_DRV2605
|
||||
url = https://github.com/adafruit/Adafruit_CircuitPython_DRV2605
|
||||
[submodule "frozen/Adafruit_CircuitPython_BLE"]
|
||||
path = frozen/Adafruit_CircuitPython_BLE
|
||||
url = https://github.com/adafruit/Adafruit_CircuitPython_BLE
|
||||
[submodule "frozen/Adafruit_CircuitPython_BLE_Apple_Notification_Center"]
|
||||
path = frozen/Adafruit_CircuitPython_BLE_Apple_Notification_Center
|
||||
url = https://github.com/adafruit/Adafruit_CircuitPython_BLE_Apple_Notification_Center
|
||||
[submodule "ports/esp32s2/esp-idf"]
|
||||
path = ports/esp32s2/esp-idf
|
||||
url = https://github.com/tannewt/esp-idf.git
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
# SPDX-FileCopyrightText: 2020 Diego Elio Pettenò
|
||||
#
|
||||
# SPDX-License-Identifier: Unlicense
|
||||
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v2.3.0
|
||||
hooks:
|
||||
- id: check-yaml
|
||||
- id: end-of-file-fixer
|
||||
exclude: '^(tests/.*\.exp|tests/cmdline/.*|tests/.*/data/.*)'
|
||||
- id: trailing-whitespace
|
||||
exclude: '^(tests/.*\.exp|tests/cmdline/.*|tests/.*/data/.*)'
|
|
@ -1,2 +1,10 @@
|
|||
# .readthedocs.yml
|
||||
# Read the Docs configuration file
|
||||
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
|
||||
|
||||
version: 2
|
||||
|
||||
python:
|
||||
version: 3
|
||||
install:
|
||||
- requirements: docs/requirements.txt
|
||||
|
|
137
.travis.yml
137
.travis.yml
|
@ -1,137 +0,0 @@
|
|||
sudo: required
|
||||
dist: xenial
|
||||
language: c
|
||||
compiler:
|
||||
- gcc
|
||||
git:
|
||||
depth: 1
|
||||
|
||||
# Each item under 'env' is a separate Travis job to execute.
|
||||
# They run in separate environments, so each one must take the time
|
||||
# to clone the repository and submodules; to download and install SDKs,
|
||||
# pip packages, and so forth. By gathering activities together in optimal
|
||||
# ways, the "run time" and "total time" of the travis jobs can be minimized.
|
||||
#
|
||||
# Since at the time of writing Travis generally starts 5 or 6 jobs, the
|
||||
# builds have been organized into 5 groups of *approximately* equal durations.
|
||||
# Additionally, the jobs that need extra SDKs are also organized together.
|
||||
#
|
||||
# When adding new boards, take a look on the travis CI page
|
||||
# https://travis-ci.org/adafruit/circuitpython to which build that installs
|
||||
# that SDK is shortest and add it there. In the case of major re-organizations,
|
||||
# just try to make the builds "about equal in run time"
|
||||
env:
|
||||
- TRAVIS_TESTS="unix docs translations website" TRAVIS_BOARDS="feather_huzzah circuitplayground_express mini_sam_m4 grandcentral_m4_express pca10056 pca10059 feather_nrf52832 feather_nrf52840_express makerdiary_nrf52840_mdk" TRAVIS_SDK=arm:nrf:esp8266
|
||||
- TRAVIS_BOARDS="metro_m0_express metro_m4_express pirkey_m0 trellis_m4_express trinket_m0" TRAVIS_SDK=arm
|
||||
- TRAVIS_BOARDS="feather_radiofruit_zigbee gemma_m0 hallowing_m0_express itsybitsy_m0_express itsybitsy_m4_express meowmeow" TRAVIS_SDK=arm
|
||||
- TRAVIS_BOARDS="feather_m0_express_crickit feather_m0_rfm69 feather_m0_rfm9x feather_m4_express arduino_zero arduino_mkr1300" TRAVIS_SDK=arm
|
||||
- TRAVIS_BOARDS="circuitplayground_express_crickit feather_m0_adalogger feather_m0_basic feather_m0_express catwan_usbstick" TRAVIS_SDK=arm
|
||||
|
||||
addons:
|
||||
artifacts:
|
||||
paths:
|
||||
- $(ls -d1 bin/*/* | tr "\n" ":")
|
||||
target_paths: /
|
||||
|
||||
deploy:
|
||||
provider: releases
|
||||
api_key:
|
||||
secure: "jdqVFw6itRY4qwQF4ReXo0uaymT+Mob6RhYX0lw8KWFNqBgHnLVuKmKKcGMEuRvBVMPkvxF7bMuOQzSBOunqwlHFse3oMzdWvQODv1zwV7pSRXGwTdIvTPbBjKWxnBG9uSNRf2R5AMflJFUxy2CbtBpgvNzr+4VLREZDrrjEu8C1iTtXGpSm5AQ5iIp2fkMAWD85FP7CQPpkqRoxhSIFZmTdurfYRmenq1OZ/4SeD5TESKcyvqJNzVT9z210B3cg3eAkP6ukvelW4qE2zgIANqUkGqvDEnAvEII9M89kuwhCMAekdfwnUSPrry+g77i1dUZHoRN1+MFj+waYtPaqxdYo2G1sysa6enxlu4jHMR5MfMk9eKHgaNgL3PiyANusYSS44amh8QIiVaX5nw82myZDCpQOZW7YqJKE6WX70Lbs4mS+wIs+ig4KIXO1B0p9kMb0OeVjHRl+KcXsWGRu/ECG/ExpqlVIssSPU407LohMXT2cJ37CY/R/EeK2XSDsQ2M3L3EAGUjCJdBGuwsOJ+2lG+HQpAVu9vAB4kq5jy9Ye+MG+8Xlkly3XZZ5+FkXyYxKnXb26/QVv0e5sIG5OmdJCPYFaH2J1QdKo7CdhEcBtrf6DMPWaimGMldShFqzLjOz3b3qLysRxFF0aGb7ipKPa57vawNzYHoPAViOcXQ="
|
||||
file:
|
||||
- $(ls -d1 bin/*/* | tr "\n" ":")
|
||||
skip_cleanup: true
|
||||
draft: true
|
||||
on:
|
||||
tags: true
|
||||
|
||||
notifications:
|
||||
webhooks:
|
||||
urls:
|
||||
- https://rosie-ci.ngrok.io/travis
|
||||
on_success: always
|
||||
on_failure: always
|
||||
on_start: always
|
||||
on_cancel: always
|
||||
on_error: always
|
||||
|
||||
before_script:
|
||||
# Expand the git tree back to 4.0.0-alpha.1 and then fetch the latest tag.
|
||||
- LAST_TAG=`git ls-remote --quiet --tags --sort=version:refname | egrep -o "refs/tags/[0-9]+.*\$" | tail -n 1`
|
||||
- git fetch --shallow-exclude=4.0.0-alpha.1 || git fetch --unshallow
|
||||
- git fetch --depth 1 origin $LAST_TAG:$LAST_TAG
|
||||
- git describe --dirty --always --tags
|
||||
- function var_search () { case "$1" in *$2*) true;; *) false;; esac; }
|
||||
- sudo dpkg --add-architecture i386
|
||||
|
||||
|
||||
- (! var_search "${TRAVIS_SDK-}" arm || (wget https://s3.amazonaws.com/adafruit-circuit-python/gcc-arm-embedded_7-2018q2-1~xenial1_amd64.deb && sudo dpkg -i gcc-arm-embedded*_amd64.deb))
|
||||
|
||||
# For nrf builds
|
||||
- (! var_search "${TRAVIS_SDK-}" nrf || sudo ports/nrf/bluetooth/download_ble_stack.sh)
|
||||
|
||||
# For huzzah builds
|
||||
- (! var_search "${TRAVIS_SDK-}" esp8266 || (wget https://github.com/jepler/esp-open-sdk/releases/download/2018-06-10/xtensa-lx106-elf-standalone.tar.gz && tar -C .. -xaf xtensa-lx106-elf-standalone.tar.gz))
|
||||
- if var_search "${TRAVIS_SDK-}" esp8266 ; then PATH=$(readlink -f ../xtensa-lx106-elf/bin):$PATH; fi
|
||||
|
||||
# For coverage testing (upgrade is used to get latest urllib3 version)
|
||||
- sudo apt-get install -y python3-pip
|
||||
- pip3 install --user sh click
|
||||
- ([[ -z "$TRAVIS_TESTS" ]] || sudo pip install --upgrade cpp-coveralls)
|
||||
- (! var_search "${TRAVIS_TESTS-}" docs || pip install --user 'Sphinx<1.8.0' sphinx-rtd-theme recommonmark)
|
||||
- (! var_search "${TRAVIS_TESTS-}" translations || pip3 install --user polib)
|
||||
|
||||
# report some good version numbers to the build
|
||||
- gcc --version
|
||||
- (! var_search "${TRAVIS_SDK-}" arm || arm-none-eabi-gcc --version)
|
||||
- (! var_search "${TRAVIS_SDK-}" esp8266 || xtensa-lx106-elf-gcc --version)
|
||||
- python3 --version
|
||||
|
||||
script:
|
||||
# Build mpy-cross first because other builds depend on it.
|
||||
- echo 'Building mpy-cross' && echo -en 'travis_fold:start:mpy-cross\\r'
|
||||
- make -C mpy-cross -j2
|
||||
- echo -en 'travis_fold:end:mpy-cross\\r'
|
||||
|
||||
- cd tools && python3 build_adafruit_bins.py
|
||||
- cd ..
|
||||
|
||||
- echo 'Building unix' && echo -en 'travis_fold:start:unix\\r'
|
||||
- (! var_search "${TRAVIS_TESTS-}" unix || (make -C ports/unix deplibs -j2 && make -C ports/unix -j2 && make -C ports/unix coverage -j2))
|
||||
- echo -en 'travis_fold:end:unix\\r'
|
||||
|
||||
# run tests without coverage info
|
||||
#- (cd tests && MICROPY_CPYTHON3=python3.4 ./run-tests -j1)
|
||||
#- (cd tests && MICROPY_CPYTHON3=python3.4 ./run-tests -j1 --emit native)
|
||||
|
||||
# run tests with coverage info
|
||||
- echo 'Test all' && echo -en 'travis_fold:start:test_all\\r'
|
||||
- (! var_search "${TRAVIS_TESTS-}" unix || (cd tests && MICROPY_CPYTHON3=python3.5 MICROPY_MICROPYTHON=../ports/unix/micropython_coverage ./run-tests -j1))
|
||||
- echo -en 'travis_fold:end:test_all\\r'
|
||||
|
||||
- echo 'Test threads' && echo -en 'travis_fold:start:test_threads\\r'
|
||||
- (! var_search "${TRAVIS_TESTS-}" unix || (cd tests && MICROPY_CPYTHON3=python3.5 MICROPY_MICROPYTHON=../ports/unix/micropython_coverage ./run-tests -j1 -d thread))
|
||||
- echo -en 'travis_fold:end:test_threads\\r'
|
||||
|
||||
- echo 'Testing with native' && echo -en 'travis_fold:start:test_native\\r'
|
||||
- (! var_search "${TRAVIS_TESTS-}" unix || (cd tests && MICROPY_CPYTHON3=python3.5 MICROPY_MICROPYTHON=../ports/unix/micropython_coverage ./run-tests -j1 --emit native))
|
||||
- echo -en 'travis_fold:end:test_native\\r'
|
||||
|
||||
- (echo 'Testing with mpy' && echo -en 'travis_fold:start:test_mpy\\r')
|
||||
- (! var_search "${TRAVIS_TESTS-}" unix || (cd tests && MICROPY_CPYTHON3=python3.5 MICROPY_MICROPYTHON=../ports/unix/micropython_coverage ./run-tests -j1 --via-mpy -d basics float))
|
||||
- echo -en 'travis_fold:end:test_mpy\\r'
|
||||
|
||||
- (echo 'Building docs' && echo -en 'travis_fold:start:build_docs\\r')
|
||||
- (! var_search "${TRAVIS_TESTS-}" docs || sphinx-build -E -W -b html . _build/html)
|
||||
- echo -en 'travis_fold:end:build_docs\\r'
|
||||
|
||||
- (echo 'Building translations' && echo -en 'travis_fold:start:build_translations\\r')
|
||||
- (! var_search "${TRAVIS_TESTS-}" translations || make check-translate)
|
||||
- echo -en 'travis_fold:end:build_translations\\r'
|
||||
|
||||
# run coveralls coverage analysis (try to, even if some builds/tests failed)
|
||||
#- (cd ports/unix && coveralls --root ../.. --build-root . --gcov $(which gcov) --gcov-options '\-o build-coverage/' --include py --include extmod)
|
||||
|
||||
- (! var_search "${TRAVIS_TESTS-}" website || (cd tools && python3 build_board_info.py && cd ..))
|
||||
|
||||
after_failure:
|
||||
- (cd tests && for exp in *.exp; do testbase=$(basename $exp .exp); echo -e "\nFAILURE $testbase"; diff -u $testbase.exp $testbase.out; done)
|
|
@ -0,0 +1,82 @@
|
|||
|
||||
# Building CircuitPython
|
||||
|
||||
Welcome to CircuitPython!
|
||||
|
||||
This document is a quick-start guide only.
|
||||
|
||||
Detailed guides on how to build CircuitPython can be found in the Adafruit Learn system at
|
||||
https://learn.adafruit.com/building-circuitpython/
|
||||
|
||||
## Setup
|
||||
|
||||
Please ensure you setup your build environment appropriately, as per the guide. You will need:
|
||||
|
||||
* Linux: https://learn.adafruit.com/building-circuitpython/linux
|
||||
* MacOS: https://learn.adafruit.com/building-circuitpython/macos
|
||||
* Windows Subsystem for Linux (WSL): https://learn.adafruit.com/building-circuitpython/windows-subsystem-for-linux
|
||||
|
||||
### Submodules
|
||||
|
||||
This project has a bunch of git submodules. You will need to update them regularly.
|
||||
|
||||
git submodule sync
|
||||
git submodule update --init
|
||||
|
||||
### mpy-cross
|
||||
|
||||
As part of the build process, mpy-cross is needed to compile .py files into .mpy files.
|
||||
To compile (or recompile) mpy-cross:
|
||||
|
||||
make -C mpy-cross
|
||||
|
||||
# Building
|
||||
|
||||
There a number of ports of CircuitPython! To build for your board, change to the appropriate ports directory and build.
|
||||
|
||||
Examples:
|
||||
|
||||
cd ports/atmel-samd
|
||||
make BOARD=circuitplayground_express
|
||||
|
||||
cd ports/nrf
|
||||
make BOARD=circuitplayground_bluefruit
|
||||
|
||||
If you aren't sure what boards exist, have a peek in the boards subdirectory of your port.
|
||||
If you have a fast computer with many cores, consider adding `-j` to your build flags, such as `-j17` on
|
||||
a 6-core 12-thread machine.
|
||||
|
||||
# Testing
|
||||
|
||||
If you are working on changes to the core language, you might find it useful to run the test suite.
|
||||
The test suite in the top level `tests` directory. It needs the unix port to run.
|
||||
|
||||
cd ports/unix
|
||||
make axtls
|
||||
make micropython
|
||||
|
||||
Then you can run the test suite:
|
||||
|
||||
cd ../../tests
|
||||
./run-tests
|
||||
|
||||
A successful run will say something like
|
||||
|
||||
676 tests performed (19129 individual testcases)
|
||||
676 tests passed
|
||||
30 tests skipped: buffered_writer builtin_help builtin_range_binop class_delattr_setattr cmd_parsetree extra_coverage framebuf1 framebuf16 framebuf2 framebuf4 framebuf8 framebuf_subclass mpy_invalid namedtuple_asdict non_compliant resource_stream schedule sys_getsizeof urandom_extra ure_groups ure_span ure_sub ure_sub_unmatched vfs_basic vfs_fat_fileio1 vfs_fat_fileio2 vfs_fat_more vfs_fat_oldproto vfs_fat_ramdisk vfs_userfs
|
||||
|
||||
# Debugging
|
||||
|
||||
The easiest way to debug CircuitPython on hardware is with a JLink device, JLinkGDBServer, and an appropriate GDB.
|
||||
Instructions can be found at https://learn.adafruit.com/debugging-the-samd21-with-gdb
|
||||
|
||||
If using JLink, you'll need both the `JLinkGDBServer` and `arm-none-eabi-gdb` running.
|
||||
|
||||
Example:
|
||||
|
||||
JLinkGDBServer -if SWD -device ATSAMD51J19
|
||||
arm-none-eabi-gdb build-metro_m4_express/firmware.elf -iex "target extended-remote :2331"
|
||||
|
||||
If your port/build includes `arm-none-eabi-gdb-py`, consider using it instead, as it can be used for better register
|
||||
debugging with https://github.com/bnahill/PyCortexMDebug
|
|
@ -1,74 +1,135 @@
|
|||
# Contributor Covenant Code of Conduct
|
||||
<!--
|
||||
SPDX-FileCopyrightText: 2014 Coraline Ada Ehmke
|
||||
SPDX-FileCopyrightText: 2019 Kattni Rembor for Adafruit Industries
|
||||
|
||||
SPDX-License-Identifier: CC-BY-4.0
|
||||
-->
|
||||
# Adafruit Community Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as
|
||||
contributors and maintainers pledge to making participation in our project and
|
||||
contributors and leaders pledge to making participation in our project and
|
||||
our community a harassment-free experience for everyone, regardless of age, body
|
||||
size, disability, ethnicity, gender identity and expression, level of experience,
|
||||
nationality, personal appearance, race, religion, or sexual identity and
|
||||
orientation.
|
||||
size, disability, ethnicity, gender identity and expression, level or type of
|
||||
experience, education, socio-economic status, nationality, personal appearance,
|
||||
race, religion, or sexual identity and orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
We are committed to providing a friendly, safe and welcoming environment for
|
||||
all.
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment
|
||||
include:
|
||||
|
||||
* Be kind and courteous to others
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Collaborating with other community members
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or
|
||||
advances
|
||||
* The use of sexualized language or imagery and sexual attention or advances
|
||||
* The use of inappropriate images, including in a community member's avatar
|
||||
* The use of inappropriate language, including in a community member's nickname
|
||||
* Any spamming, flaming, baiting or other attention-stealing behavior
|
||||
* Excessive or unwelcome helping; answering outside the scope of the question
|
||||
asked
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Promoting or spreading disinformation, lies, or conspiracy theories against
|
||||
a person, group, organisation, project, or community
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic
|
||||
address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
* Other conduct which could reasonably be considered inappropriate
|
||||
|
||||
The goal of the standards and moderation guidelines outlined here is to build
|
||||
and maintain a respectful community. We ask that you don’t just aim to be
|
||||
"technically unimpeachable", but rather try to be your best self.
|
||||
|
||||
We value many things beyond technical expertise, including collaboration and
|
||||
supporting others within our community. Providing a positive experience for
|
||||
other community members can have a much more significant impact than simply
|
||||
providing the correct answer.
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable
|
||||
Project leaders are responsible for clarifying the standards of acceptable
|
||||
behavior and are expected to take appropriate and fair corrective action in
|
||||
response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or
|
||||
reject comments, commits, code, wiki edits, issues, and other contributions
|
||||
Project leaders have the right and responsibility to remove, edit, or
|
||||
reject messages, comments, commits, code, issues, and other contributions
|
||||
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||
permanently any contributor for other behaviors that they deem inappropriate,
|
||||
threatening, offensive, or harmful.
|
||||
permanently any community member for other behaviors that they deem
|
||||
inappropriate, threatening, offensive, or harmful.
|
||||
|
||||
## Moderation
|
||||
|
||||
Instances of behaviors that violate the Adafruit Community Code of Conduct
|
||||
may be reported by any member of the community. Community members are
|
||||
encouraged to report these situations, including situations they witness
|
||||
involving other community members.
|
||||
|
||||
You may report in the following ways:
|
||||
|
||||
In any situation, you may send an email to <support@adafruit.com>.
|
||||
|
||||
On the Adafruit Discord, you may send an open message from any channel
|
||||
to all Community Moderators by tagging @community moderators. You may
|
||||
also send an open message from any channel, or a direct message to
|
||||
@kattni#1507, @tannewt#4653, @danh#1614, @cater#2442,
|
||||
@sommersoft#0222, @Mr. Certainly#0472 or @Andon#8175.
|
||||
|
||||
Email and direct message reports will be kept confidential.
|
||||
|
||||
In situations on Discord where the issue is particularly egregious, possibly
|
||||
illegal, requires immediate action, or violates the Discord terms of service,
|
||||
you should also report the message directly to Discord.
|
||||
|
||||
These are the steps for upholding our community’s standards of conduct.
|
||||
|
||||
1. Any member of the community may report any situation that violates the
|
||||
Adafruit Community Code of Conduct. All reports will be reviewed and
|
||||
investigated.
|
||||
2. If the behavior is an egregious violation, the community member who
|
||||
committed the violation may be banned immediately, without warning.
|
||||
3. Otherwise, moderators will first respond to such behavior with a warning.
|
||||
4. Moderators follow a soft "three strikes" policy - the community member may
|
||||
be given another chance, if they are receptive to the warning and change their
|
||||
behavior.
|
||||
5. If the community member is unreceptive or unreasonable when warned by a
|
||||
moderator, or the warning goes unheeded, they may be banned for a first or
|
||||
second offense. Repeated offenses will result in the community member being
|
||||
banned.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct and the enforcement policies listed above apply to all
|
||||
Adafruit Community venues. This includes but is not limited to any community
|
||||
spaces (both public and private), the entire Adafruit Discord server, and
|
||||
Adafruit GitHub repositories. Examples of Adafruit Community spaces include
|
||||
but are not limited to meet-ups, audio chats on the Adafruit Discord, or
|
||||
interaction at a conference.
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces
|
||||
when an individual is representing the project or its community. Examples of
|
||||
representing a project or community include using an official project e-mail
|
||||
address, posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event. Representation of a project may be
|
||||
further defined and clarified by project maintainers.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported by contacting the project team at support@adafruit.com. All
|
||||
complaints will be reviewed and investigated and will result in a response that
|
||||
is deemed necessary and appropriate to the circumstances. The project team is
|
||||
obligated to maintain confidentiality with regard to the reporter of an incident.
|
||||
Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good
|
||||
faith may face temporary or permanent repercussions as determined by other
|
||||
members of the project's leadership.
|
||||
when an individual is representing the project or its community. As a community
|
||||
member, you are representing our community, and are expected to behave
|
||||
accordingly.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
||||
available at [http://contributor-covenant.org/version/1/4][version]
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
||||
version 1.4, available at
|
||||
<https://www.contributor-covenant.org/version/1/4/code-of-conduct.html>,
|
||||
and the [Rust Code of Conduct](https://www.rust-lang.org/en-US/conduct.html).
|
||||
|
||||
[homepage]: http://contributor-covenant.org
|
||||
[version]: http://contributor-covenant.org/version/1/4/
|
||||
For other projects adopting the Adafruit Community Code of
|
||||
Conduct, please contact the maintainers of those projects for enforcement.
|
||||
If you wish to use this code of conduct for your own project, consider
|
||||
explicitly mentioning your moderation policy or making a copy with your
|
||||
own moderation policy so as to avoid confusion.
|
||||
|
|
|
@ -14,7 +14,15 @@ If you have an employment contract with your employer please make sure that they
|
|||
don't automatically own your work product. Make sure to get any necessary approvals
|
||||
before contributing. Another term for this contribution off-hours is moonlighting.
|
||||
|
||||
## Getting started
|
||||
## Ways to contribute
|
||||
As CircuitPython grows, there are more and more ways to contribute. Here are some ideas:
|
||||
|
||||
* Build a project with CircuitPython and share how to do it online.
|
||||
* Test the latest libraries and CircuitPython versions with your projects and file issues for any bugs you find.
|
||||
* Contribute Python code to CircuitPython libraries that support new devices or features of an existing device.
|
||||
* Contribute C code to CircuitPython which fixes an open issue or adds a new feature.
|
||||
|
||||
## Getting started with C
|
||||
CircuitPython developer Dan Halbert (@dhalbert) has written up build instructions using native build
|
||||
tools [here](https://learn.adafruit.com/building-circuitpython).
|
||||
|
||||
|
|
56
Makefile
56
Makefile
|
@ -1,4 +1,4 @@
|
|||
# Makefile for Sphinx documentation
|
||||
# Top-level Makefile for documentation builds and miscellaneous tasks.
|
||||
#
|
||||
|
||||
# You can set these variables from the command line.
|
||||
|
@ -17,6 +17,13 @@ CONFDIR = .
|
|||
FORCE = -E
|
||||
VERBOSE = -v
|
||||
|
||||
# path to generated type stubs
|
||||
STUBDIR = circuitpython-stubs
|
||||
# Run "make VALIDATE= stubs" to avoid validating generated stub files
|
||||
VALIDATE = -v
|
||||
# path to pypi source distributions
|
||||
DISTDIR = dist
|
||||
|
||||
# Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the
|
||||
# full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the
|
||||
# executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/)
|
||||
|
@ -29,7 +36,9 @@ ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(BASEOPTS)
|
|||
# the i18n builder cannot share the environment and doctrees with the others
|
||||
I18NSPHINXOPTS = $(BASEOPTS)
|
||||
|
||||
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
|
||||
TRANSLATE_SOURCES = extmod lib main.c ports/atmel-samd ports/cxd56 ports/mimxrt10xx ports/nrf ports/stm py shared-bindings shared-module supervisor
|
||||
|
||||
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext stubs
|
||||
|
||||
help:
|
||||
@echo "Please use \`make <target>' where <target> is one of"
|
||||
|
@ -58,8 +67,10 @@ help:
|
|||
|
||||
clean:
|
||||
rm -rf $(BUILDDIR)/*
|
||||
rm -rf autoapi
|
||||
rm -rf $(STUBDIR) $(DISTDIR) *.egg-info
|
||||
|
||||
html:
|
||||
html: stubs
|
||||
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
|
||||
@echo
|
||||
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
|
||||
|
@ -191,13 +202,44 @@ pseudoxml:
|
|||
@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
|
||||
|
||||
# phony target so we always run
|
||||
.PHONY: all-source
|
||||
all-source:
|
||||
|
||||
locale/circuitpython.pot: all-source
|
||||
find . -iname "*.c" | xargs xgettext -L C --keyword=translate -F -o circuitpython.pot -p locale
|
||||
find $(TRANSLATE_SOURCES) -iname "*.c" -print | (LC_ALL=C sort) | xgettext -f- -L C -s --add-location=file --keyword=translate -o circuitpython.pot -p locale
|
||||
|
||||
# Historically, `make translate` updated the .pot file and ran msgmerge.
|
||||
# However, this was a frequent source of merge conflicts. Weblate can perform
|
||||
# msgmerge, so make translate merely update the translation template file.
|
||||
.PHONY: translate
|
||||
translate: locale/circuitpython.pot
|
||||
for po in $(shell ls locale/*.po); do msgmerge -U -F $$po locale/circuitpython.pot; done
|
||||
|
||||
check-translate: locale/circuitpython.pot $(wildcard locale/*.po)
|
||||
$(PYTHON) tools/check_translations.py $^
|
||||
# Note that normally we rely on weblate to perform msgmerge. This reduces the
|
||||
# chance of a merge conflict between developer changes (that only add and
|
||||
# remove source strings) and weblate changes (that only add and remove
|
||||
# translated strings from po files). However, in case this is legitimately
|
||||
# needed we preserve a rule to do it.
|
||||
.PHONY: msgmerge
|
||||
msgmerge:
|
||||
for po in $(shell ls locale/*.po); do msgmerge -U $$po -s --no-fuzzy-matching --add-location=file locale/circuitpython.pot; done
|
||||
|
||||
merge-translate:
|
||||
git merge HEAD 1>&2 2> /dev/null; test $$? -eq 128
|
||||
rm locale/*~ || true
|
||||
git checkout --theirs -- locale/*
|
||||
make translate
|
||||
|
||||
.PHONY: check-translate
|
||||
check-translate:
|
||||
find $(TRANSLATE_SOURCES) -iname "*.c" -print | (LC_ALL=C sort) | xgettext -f- -L C -s --add-location=file --keyword=translate -o circuitpython.pot.tmp -p locale
|
||||
$(PYTHON) tools/check_translations.py locale/circuitpython.pot.tmp locale/circuitpython.pot; status=$$?; rm -f locale/circuitpython.pot.tmp; exit $$status
|
||||
|
||||
stubs:
|
||||
@mkdir -p circuitpython-stubs
|
||||
@$(PYTHON) tools/extract_pyi.py shared-bindings/ $(STUBDIR)
|
||||
@$(PYTHON) tools/extract_pyi.py ports/atmel-samd/bindings $(STUBDIR)
|
||||
@$(PYTHON) setup.py -q sdist
|
||||
|
||||
update-frozen-libraries:
|
||||
@echo "Updating all frozen libraries to latest tagged version."
|
||||
cd frozen; for library in *; do cd $$library; ../../tools/git-checkout-latest-tag.sh; cd ..; done
|
||||
|
|
221
README.rst
221
README.rst
|
@ -1,90 +1,46 @@
|
|||
Adafruit CircuitPython
|
||||
======================
|
||||
CircuitPython
|
||||
=============
|
||||
|
||||
|Build Status| |Doc Status| |Discord|
|
||||
.. image:: https://s3.amazonaws.com/adafruit-circuit-python/CircuitPython_Repo_header_logo.png
|
||||
|
||||
`Status <#status>`__ \| `Supported Boards <#supported-boards>`__
|
||||
\| `Download <#download>`__ \|
|
||||
`Documentation <#documentation>`__ \|
|
||||
`Contributing <#contributing>`__ \| `Differences from
|
||||
Micropython <#differences-from-micropython>`__ \| `Project
|
||||
Structure <#project-structure>`__
|
||||
|Build Status| |Doc Status| |License| |Discord| |Weblate|
|
||||
|
||||
**CircuitPython** is an *education friendly* open source derivative of
|
||||
`MicroPython <https://micropython.org>`_. CircuitPython supports use
|
||||
on educational development boards designed and sold by
|
||||
`Adafruit <https://adafruit.com>`_. Adafruit CircuitPython features
|
||||
unified Python core APIs and a growing list of Adafruit libraries and
|
||||
drivers of that work with it.
|
||||
`circuitpython.org <https://circuitpython.org>`__ \| `Get CircuitPython <#get-circuitpython>`__ \|
|
||||
`Documentation <#documentation>`__ \| `Contributing <#contributing>`__ \|
|
||||
`Branding <#branding>`__ \| `Differences from Micropython <#differences-from-micropython>`__ \|
|
||||
`Project Structure <#project-structure>`__
|
||||
|
||||
Status
|
||||
------
|
||||
**CircuitPython** is a *beginner friendly*, open source version of Python for tiny, inexpensive
|
||||
computers called microcontrollers. Microcontrollers are the brains of many electronics including a
|
||||
wide variety of development boards used to build hobby projects and prototypes. CircuitPython in
|
||||
electronics is one of the best ways to learn to code because it connects code to reality. Simply
|
||||
install CircuitPython on a supported board via drag and drop and then edit a ``code.py`` file on
|
||||
the CIRCUITPY drive. The code will automatically reload. No software installs are needed besides a
|
||||
text editor (we recommend `Mu <https://codewith.mu/>`_ for beginners.)
|
||||
|
||||
This project is stable. Most APIs should be stable going forward. Those
|
||||
that change will change on major version numbers such as 2.0.0 and
|
||||
3.0.0.
|
||||
CircuitPython features unified Python core APIs and a growing list of 150+ device libraries and
|
||||
drivers that work with it. These libraries also work on single board computers with regular
|
||||
Python via the `Adafruit Blinka Library <https://github.com/adafruit/Adafruit_Blinka>`_.
|
||||
|
||||
Supported Boards
|
||||
----------------
|
||||
CircuitPython is based on `MicroPython <https://micropython.org>`_. See
|
||||
`below <#differences-from-micropython>`_ for differences. CircuitPython development is sponsored by
|
||||
`Adafruit <https://adafruit.com>`_ and is available on their educational development boards. Please
|
||||
support both MicroPython and Adafruit.
|
||||
|
||||
Designed for CircuitPython
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Get CircuitPython
|
||||
------------------
|
||||
|
||||
**M0 Boards**
|
||||
|
||||
- `Adafruit CircuitPlayground Express <https://www.adafruit.com/product/3333>`__ (`CircuitPython Guide <https://learn.adafruit.com/adafruit-circuit-playground-express/circuitpython-quickstart>`__)
|
||||
- `Adafruit Feather M0 Express <https://www.adafruit.com/product/3403>`__ (`CircuitPython Guide <https://learn.adafruit.com/adafruit-feather-m0-express-designed-for-circuit-python-circuitpython/kattni-circuitpython>`__)
|
||||
- `Adafruit Gemma M0 <https://www.adafruit.com/product/3501>`__ (`CircuitPython Guide <https://learn.adafruit.com/adafruit-gemma-m0/circuitpython>`__)
|
||||
- `Adafruit Hallowing M0 Express <https://www.adafruit.com/product/3900>`__ (`CircuitPython Guide <https://learn.adafruit.com/adafruit-hallowing/circuitpython>`__)
|
||||
- `Adafruit ItsyBitsy M0 Express <https://www.adafruit.com/product/3727>`_ (`CircuitPython Guide <https://learn.adafruit.com/introducing-itsy-bitsy-m0/circuitpython>`__)
|
||||
- `Adafruit Metro M0 Express <https://www.adafruit.com/product/3505>`_ (`CircuitPython Guide <https://learn.adafruit.com/adafruit-metro-m0-express-designed-for-circuitpython/circuitpython>`__)
|
||||
- `Adafruit Trinket M0 <https://www.adafruit.com/product/3500>`__ (`CircuitPython Guide <https://learn.adafruit.com/adafruit-trinket-m0-circuitpython-arduino/circuitpython>`__)
|
||||
|
||||
**M4 Boards**
|
||||
|
||||
- `Adafruit Feather M4 Express <https://www.adafruit.com/product/3857>`__ (`CircuitPython Guide <https://learn.adafruit.com/adafruit-feather-m4-express-atsamd51/circuitpython>`__)
|
||||
- `Adafruit ItsyBitsy M4 Express <https://www.adafruit.com/product/3800>`__ (`CircuitPython Guide <https://learn.adafruit.com/introducing-adafruit-itsybitsy-m4/circuitpython>`__)
|
||||
- `Adafruit Metro M4 Express <https://www.adafruit.com/product/3382>`__ (`CircuitPython Guide <https://learn.adafruit.com/adafruit-metro-m4-express-featuring-atsamd51/circuitpython>`__)
|
||||
|
||||
Other
|
||||
~~~~~
|
||||
|
||||
- `Adafruit Feather HUZZAH <https://www.adafruit.com/products/2821>`__
|
||||
- `Adafruit Feather M0
|
||||
Basic <https://www.adafruit.com/products/2772>`__
|
||||
- `Adafruit Feather M0 Bluefruit
|
||||
LE <https://www.adafruit.com/products/2995>`__ (uses M0 Basic
|
||||
binaries)
|
||||
- `Adafruit Feather M0
|
||||
Adalogger <https://www.adafruit.com/product/2796>`__ (MicroSD card
|
||||
supported using the `Adafruit CircuitPython SD
|
||||
library <https://github.com/adafruit/Adafruit_CircuitPython_SD>`__)
|
||||
- `Arduino Zero <https://www.arduino.cc/en/Main/ArduinoBoardZero>`__
|
||||
|
||||
"Third-party" or "non-Adafruit" boards
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
- `Electronic Cats Meow Meow <https://electroniccats.com/gomeow/>`__
|
||||
- `Electronic Cats CatWAN USB Stick <https://electroniccats.com/producto/catwan_usb_stick/>`__
|
||||
|
||||
|
||||
Download
|
||||
--------
|
||||
|
||||
Official binaries are available through the `latest GitHub
|
||||
releases <https://github.com/adafruit/circuitpython/releases>`__.
|
||||
Continuous (one per commit) builds are available
|
||||
`here <https://adafruit-circuit-python.s3.amazonaws.com/index.html?prefix=bin>`__
|
||||
and includes experimental hardware support.
|
||||
Official binaries for all supported boards are available through
|
||||
`circuitpython.org/downloads <https://circuitpython.org/downloads>`_. The site includes stable, unstable and
|
||||
continuous builds. Full release notes and assets are available through
|
||||
`GitHub releases <https://github.com/adafruit/circuitpython/releases>`_ as well.
|
||||
|
||||
Documentation
|
||||
-------------
|
||||
|
||||
Guides and videos are available through the `Adafruit Learning
|
||||
System <https://learn.adafruit.com/>`__ under the `CircuitPython
|
||||
category <https://learn.adafruit.com/category/circuitpython>`__ and
|
||||
`MicroPython
|
||||
category <https://learn.adafruit.com/category/micropython>`__. An API
|
||||
category <https://learn.adafruit.com/category/circuitpython>`__. An API
|
||||
reference is also available on `Read the Docs
|
||||
<http://circuitpython.readthedocs.io/en/latest/?>`__. A collection of awesome
|
||||
resources can be found at `Awesome CircuitPython <https://github.com/adafruit/awesome-circuitpython>`__.
|
||||
|
@ -107,7 +63,29 @@ Contributors who follow the `Code of
|
|||
Conduct <https://github.com/adafruit/circuitpython/blob/master/CODE_OF_CONDUCT.md>`__
|
||||
are welcome to submit pull requests and they will be promptly reviewed
|
||||
by project admins. Please join the
|
||||
`Discord <https://discord.gg/nBQh6qu>`__ too.
|
||||
`Discord <https://adafru.it/discord>`__ too.
|
||||
|
||||
Branding
|
||||
------------
|
||||
|
||||
While we are happy to see CircuitPython forked and modified, we'd appreciate it if forked releases
|
||||
not use the name "CircuitPython" or the Blinka logo. "CircuitPython" means something special to
|
||||
us and those who learn about it. As a result, we'd like to make sure products referring to it meet a
|
||||
common set of requirements.
|
||||
|
||||
If you'd like to use the term "CircuitPython" and Blinka for your product here is what we ask:
|
||||
|
||||
* Your product is supported by the primary
|
||||
`"adafruit/circuitpython" <https://github.com/adafruit/circuitpython>`_ repo. This way we can
|
||||
update any custom code as we update the CircuitPython internals.
|
||||
* Your product is listed on `circuitpython.org <https://circuitpython.org>`__ (source
|
||||
`here <https://github.com/adafruit/circuitpython-org/>`_). This is to ensure that a user of your
|
||||
product can always download the latest version of CircuitPython from the standard place.
|
||||
* Your product has a user accessible USB plug which appears as a CIRCUITPY drive when plugged in.
|
||||
|
||||
If you choose not to meet these requirements, then we ask you call your version of CircuitPython
|
||||
something else (for example, SuperDuperPython) and not use the Blinka logo. You can say it is
|
||||
"CircuitPython-compatible" if most CircuitPython drivers will work with it.
|
||||
|
||||
--------------
|
||||
|
||||
|
@ -116,15 +94,13 @@ Differences from `MicroPython <https://github.com/micropython/micropython>`__
|
|||
|
||||
CircuitPython:
|
||||
|
||||
- includes a ports for MicroChip SAMD21 (Commonly known as M0 in Adafruit
|
||||
product names) and SAMD51 (M4).
|
||||
- supports only SAMD21, SAMD51, and ESP8266 ports. An nRF port is under
|
||||
development.
|
||||
- tracks MicroPython's releases (not master).
|
||||
- Longints (arbitrary-length integers) are enabled for most M0
|
||||
Express boards (those boards with SPI flash chips external
|
||||
to the microcontroller), and for all M4 builds.
|
||||
Longints are disabled on other boards due to lack of flash space.
|
||||
- Supports native USB on all boards, allowing file editing without special tools.
|
||||
- Supports only SAMD21, SAMD51, nRF52840, CXD56, STM32F4 and i.MX RT ports.
|
||||
- Tracks MicroPython's releases (not master).
|
||||
- Floats (aka decimals) are enabled for all builds.
|
||||
- Error messages are translated into 10+ languages.
|
||||
- Does not support concurrency within Python (including interrupts and threading). Some concurrency
|
||||
is achieved with native modules for tasks that require it such as audio file playback.
|
||||
|
||||
Behavior
|
||||
~~~~~~~~
|
||||
|
@ -138,8 +114,8 @@ Behavior
|
|||
output is written to ``boot_out.txt``.
|
||||
- ``code.py`` (or ``main.py``) is run after every reload until it
|
||||
finishes or is interrupted. After it is done running, the vm and
|
||||
hardware is reinitialized. **This means you cannot read state from
|
||||
``code.py`` in the REPL anymore.** CircuitPython's goal for this
|
||||
hardware is reinitialized. **This means you cannot read state from**
|
||||
``code.py`` **in the REPL anymore.** CircuitPython's goal for this
|
||||
change includes reduce confusion about pins and memory being used.
|
||||
- After ``code.py`` the REPL can be entered by pressing any key. It no
|
||||
longer shares state with ``code.py`` so it is a fresh vm.
|
||||
|
@ -149,12 +125,23 @@ Behavior
|
|||
causes nasty crashes by making it available through mass storage
|
||||
after the crash. A reset (the button) is needed after its fixed to
|
||||
get back into normal mode.
|
||||
- RGB status LED indicating CircuitPython state, and errors through a sequence of colored flashes.
|
||||
- Re-runs ``code.py`` or other main file after file system writes over USB mass storage. (Disable with
|
||||
``samd.disable_autoreload()``)
|
||||
- Entering the REPL after the main code is finished requires a key press which enters the REPL and
|
||||
disables autoreload.
|
||||
- Main is one of these: ``code.txt``, ``code.py``, ``main.py``,
|
||||
``main.txt``
|
||||
- Boot is one of these: ``settings.txt``, ``settings.py``, ``boot.py``,
|
||||
``boot.txt``
|
||||
|
||||
API
|
||||
~~~
|
||||
|
||||
- Unified hardware APIs: `audioio <https://circuitpython.readthedocs.io/en/latest/shared-bindings/audioio/__init__.html>`_, `analogio <https://circuitpython.readthedocs.io/en/latest/shared-bindings/analogio/__init__.html>`_, `busio <https://circuitpython.readthedocs.io/en/latest/shared-bindings/busio/__init__.html>`_, `digitalio <https://circuitpython.readthedocs.io/en/latest/shared-bindings/digitalio/__init__.html>`_, `pulseio <https://circuitpython.readthedocs.io/en/latest/shared-bindings/pulseio/__init__.html>`_, `touchio <https://circuitpython.readthedocs.io/en/latest/shared-bindings/touchio/__init__.html>`_, `microcontroller <https://circuitpython.readthedocs.io/en/latest/shared-bindings/microcontroller/__init__.html>`_, `board <https://circuitpython.readthedocs.io/en/latest/shared-bindings/board/__init__.html>`_, `bitbangio <https://circuitpython.readthedocs.io/en/latest/shared-bindings/bitbangio/__init__.html>`_
|
||||
- No ``machine`` API on Atmel SAMD21 port.
|
||||
- Unified hardware APIs. Documented
|
||||
`on ReadTheDocs <https://circuitpython.readthedocs.io/en/latest/shared-bindings/index.html>`_.
|
||||
- API docs are rST within the C files in ``shared-bindings``.
|
||||
- No ``machine`` API.
|
||||
|
||||
Modules
|
||||
~~~~~~~
|
||||
|
@ -174,18 +161,6 @@ Modules
|
|||
- tick count is available as
|
||||
`time.monotonic() <https://circuitpython.readthedocs.io/en/latest/shared-bindings/time/__init__.html#time.monotonic>`__
|
||||
|
||||
atmel-samd21 features
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
- RGB status LED
|
||||
- Auto-reload after file write over mass storage. (Disable with
|
||||
``samd.disable_autoreload()``)
|
||||
- Wait state after boot and main run, before REPL.
|
||||
- Main is one of these: ``code.txt``, ``code.py``, ``main.py``,
|
||||
``main.txt``
|
||||
- Boot is one of these: ``settings.txt``, ``settings.py``, ``boot.py``,
|
||||
``boot.txt``
|
||||
|
||||
--------------
|
||||
|
||||
Project Structure
|
||||
|
@ -207,7 +182,7 @@ amongst ports including CircuitPython:
|
|||
- ``extmod`` Shared C code used in multiple ports' modules.
|
||||
- ``lib`` Shared core C code including externally developed libraries
|
||||
such as FATFS.
|
||||
- ``logo`` The MicroPython logo.
|
||||
- ``logo`` The CircuitPython logo.
|
||||
- ``mpy-cross`` A cross compiler that converts Python files to byte
|
||||
code prior to being run in MicroPython. Useful for reducing library
|
||||
size.
|
||||
|
@ -227,44 +202,22 @@ Ports
|
|||
Ports include the code unique to a microcontroller line and also
|
||||
variations based on the board.
|
||||
|
||||
- ``atmel-samd`` Support for SAMD21 based boards such as `Arduino
|
||||
Zero <https://www.arduino.cc/en/Main/ArduinoBoardZero>`__, `Adafruit
|
||||
Feather M0 Basic <https://www.adafruit.com/products/2772>`__, and
|
||||
`Adafruit Feather M0 Bluefruit
|
||||
LE <https://www.adafruit.com/products/2995>`__.
|
||||
- ``bare-arm`` A bare minimum version of MicroPython for ARM MCUs.
|
||||
- ``cc3200`` Support for boards based
|
||||
`CC3200 <http://www.ti.com/product/CC3200>`__ from TI such as the
|
||||
`WiPy 1.0 <https://www.pycom.io/solutions/py-boards/wipy1/>`__.
|
||||
- ``esp8266`` Support for boards based on ESP8266 WiFi modules such as
|
||||
the `Adafruit Feather
|
||||
HUZZAH <https://www.adafruit.com/products/2821>`__.
|
||||
- ``minimal`` A minimal MicroPython port. Start with this if you want
|
||||
to port MicroPython to another microcontroller.
|
||||
- ``pic16bit`` Support for 16-bit PIC microcontrollers.
|
||||
- ``qemu-arm`` Support for ARM emulation through
|
||||
`QEMU <https://qemu.org>`__.
|
||||
- ``stmhal`` Support for boards based on STM32 microcontrollers
|
||||
including the MicroPython flagship
|
||||
`PyBoard <https://store.micropython.org/store/#/products/PYBv1_1>`__.
|
||||
- ``teensy`` Support for the Teensy line of boards such as the `Teensy
|
||||
3.1 <https://www.pjrc.com/teensy/teensy31.html>`__.
|
||||
- ``unix`` Support for UNIX.
|
||||
- ``windows`` Support for
|
||||
`Windows <https://www.microsoft.com/en-us/windows/>`__.
|
||||
- ``zephyr`` Support for `Zephyr <https://www.zephyrproject.org/>`__, a
|
||||
real-time operating system by the Linux Foundation.
|
||||
- ``atmel-samd`` Support for SAMD21 and SAMD51 based boards.
|
||||
- ``nrf`` Support for the nRF52840 based boards.
|
||||
- ``unix`` Support for UNIX. Only used for automated testing.
|
||||
|
||||
CircuitPython only maintains the ``atmel-samd`` and ``esp8266`` ports.
|
||||
The rest are here to maintain compatibility with the
|
||||
`MicroPython <https://github.com/micropython/micropython>`__ parent
|
||||
project.
|
||||
The remaining port directories not listed above are in the repo to maintain compatibility with the
|
||||
`MicroPython <https://github.com/micropython/micropython>`__ parent project.
|
||||
|
||||
`⬆ back to top <#adafruit-circuitpython>`__
|
||||
`back to top <#circuitpython>`__
|
||||
|
||||
.. |Build Status| image:: https://travis-ci.org/adafruit/circuitpython.svg?branch=master
|
||||
.. |Build Status| image:: https://travis-ci.com/adafruit/circuitpython.svg?branch=master
|
||||
:target: https://travis-ci.org/adafruit/circuitpython
|
||||
.. |Doc Status| image:: https://readthedocs.org/projects/circuitpython/badge/?version=latest
|
||||
:target: http://circuitpython.readthedocs.io/
|
||||
.. |Discord| image:: https://img.shields.io/discord/327254708534116352.svg
|
||||
:target: https://discord.gg/nBQh6qu
|
||||
:target: https://adafru.it/discord
|
||||
.. |License| image:: https://img.shields.io/badge/License-MIT-brightgreen.svg
|
||||
:target: https://choosealicense.com/licenses/mit/
|
||||
.. |Weblate| image:: https://hosted.weblate.org/widgets/circuitpython/-/svg-badge.svg
|
||||
:target: https://hosted.weblate.org/engage/circuitpython/?utm_source=widget
|
||||
|
|
81
conf.py
81
conf.py
|
@ -13,10 +13,12 @@
|
|||
# All configuration values have a default; values that are commented out
|
||||
# serve to show the default.
|
||||
|
||||
import json
|
||||
import sys
|
||||
import os
|
||||
|
||||
from recommonmark.parser import CommonMarkParser
|
||||
import recommonmark
|
||||
import subprocess
|
||||
|
||||
# If extensions (or modules to document with autodoc) are in another directory,
|
||||
# add these directories to sys.path here. If the directory is relative to the
|
||||
|
@ -24,8 +26,20 @@ from recommonmark.parser import CommonMarkParser
|
|||
sys.path.insert(0, os.path.abspath('docs'))
|
||||
sys.path.insert(0, os.path.abspath('.'))
|
||||
|
||||
import shared_bindings_matrix
|
||||
|
||||
master_doc = 'docs/index'
|
||||
|
||||
# Grab the JSON values to use while building the module support matrix
|
||||
# in 'shared-bindings/index.rst'
|
||||
|
||||
#modules_support_matrix = shared_bindings_matrix.support_matrix_excluded_boards()
|
||||
modules_support_matrix = shared_bindings_matrix.support_matrix_by_board()
|
||||
|
||||
html_context = {
|
||||
'support_matrix': modules_support_matrix
|
||||
}
|
||||
|
||||
# -- General configuration ------------------------------------------------
|
||||
|
||||
# If your documentation needs a minimal Sphinx version, state it here.
|
||||
|
@ -37,19 +51,34 @@ needs_sphinx = '1.3'
|
|||
extensions = [
|
||||
'sphinx.ext.autodoc',
|
||||
'sphinx.ext.doctest',
|
||||
'sphinxcontrib.rsvgconverter',
|
||||
'sphinx.ext.intersphinx',
|
||||
'sphinx.ext.todo',
|
||||
'sphinx.ext.coverage'
|
||||
'sphinx.ext.coverage',
|
||||
'rstjinja',
|
||||
'recommonmark',
|
||||
]
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['templates']
|
||||
|
||||
# The suffix of source filenames.
|
||||
source_suffix = ['.rst', '.md', '.c', '.h']
|
||||
source_suffix = {
|
||||
'.rst': 'restructuredtext',
|
||||
'.md': 'markdown',
|
||||
}
|
||||
|
||||
source_parsers = {'.md': CommonMarkParser,
|
||||
'.c': "c2rst.CStrip", '.h': "c2rst.CStrip"}
|
||||
subprocess.check_output(["make", "stubs"])
|
||||
extensions.append('autoapi.extension')
|
||||
|
||||
autoapi_type = 'python'
|
||||
# Uncomment this if debugging autoapi
|
||||
autoapi_keep_files = True
|
||||
autoapi_dirs = [os.path.join('circuitpython-stubs', x) for x in os.listdir('circuitpython-stubs')]
|
||||
autoapi_add_toctree_entry = False
|
||||
autoapi_options = ['members', 'undoc-members', 'private-members', 'show-inheritance', 'special-members', 'show-module-summary']
|
||||
autoapi_template_dir = 'docs/autoapi/templates'
|
||||
autoapi_python_use_implicit_namespaces = True
|
||||
|
||||
# The encoding of source files.
|
||||
#source_encoding = 'utf-8-sig'
|
||||
|
@ -59,7 +88,7 @@ source_parsers = {'.md': CommonMarkParser,
|
|||
|
||||
# General information about the project.
|
||||
project = 'Adafruit CircuitPython'
|
||||
copyright = '2014-2018, MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)'
|
||||
copyright = '2014-2020, MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)'
|
||||
|
||||
# These are overwritten on ReadTheDocs.
|
||||
# The version info for the project you're documenting, acts as replacement for
|
||||
|
@ -83,8 +112,10 @@ version = release = '0.0.0'
|
|||
# List of patterns, relative to source directory, that match files and
|
||||
# directories to ignore when looking for source files.
|
||||
exclude_patterns = ["**/build*",
|
||||
".git",
|
||||
".venv",
|
||||
".direnv",
|
||||
"docs/autoapi",
|
||||
"docs/README.md",
|
||||
"drivers",
|
||||
"examples",
|
||||
|
@ -105,32 +136,25 @@ exclude_patterns = ["**/build*",
|
|||
"ports/atmel-samd/peripherals",
|
||||
"ports/atmel-samd/QTouch",
|
||||
"ports/atmel-samd/tools",
|
||||
"ports/bare-arm",
|
||||
"ports/cc3200",
|
||||
"ports/cc3200/FreeRTOS",
|
||||
"ports/cc3200/hal",
|
||||
"ports/esp32",
|
||||
"ports/esp8266/boards",
|
||||
"ports/esp8266/common-hal",
|
||||
"ports/esp8266/modules",
|
||||
"ports/cxd56/mkspk",
|
||||
"ports/cxd56/spresense-exported-sdk",
|
||||
"ports/esp32s2/esp-idf",
|
||||
"ports/esp32s2/peripherals",
|
||||
"ports/litex/hw",
|
||||
"ports/minimal",
|
||||
"ports/mimxrt10xx/peripherals",
|
||||
"ports/mimxrt10xx/sdk",
|
||||
"ports/nrf/device",
|
||||
"ports/nrf/bluetooth",
|
||||
"ports/nrf/modules",
|
||||
"ports/nrf/nrfx",
|
||||
"ports/nrf/peripherals",
|
||||
"ports/nrf/usb",
|
||||
"ports/pic16bit",
|
||||
"ports/qemu-arm",
|
||||
"ports/stm32",
|
||||
"ports/stm32/hal",
|
||||
"ports/stm32/cmsis",
|
||||
"ports/stm32/usbdev",
|
||||
"ports/stm32/usbhost",
|
||||
"ports/teensy",
|
||||
"ports/stm/st_driver",
|
||||
"ports/stm/packages",
|
||||
"ports/stm/peripherals",
|
||||
"ports/stm/ref",
|
||||
"ports/unix",
|
||||
"ports/windows",
|
||||
"ports/zephyr",
|
||||
"py",
|
||||
"shared-bindings/util.*",
|
||||
"shared-module",
|
||||
|
@ -284,7 +308,7 @@ latex_elements = {
|
|||
# author, documentclass [howto, manual, or own class]).
|
||||
latex_documents = [
|
||||
(master_doc, 'CircuitPython.tex', 'CircuitPython Documentation',
|
||||
'Damien P. George, Paul Sokolovsky, and contributors', 'manual'),
|
||||
'CircuitPython Contributors', 'manual'),
|
||||
]
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top of
|
||||
|
@ -314,7 +338,7 @@ latex_documents = [
|
|||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [
|
||||
('index', 'CircuitPython', 'CircuitPython Documentation',
|
||||
['Damien P. George, Paul Sokolovsky, and contributors'], 1),
|
||||
['CircuitPython contributors'], 1),
|
||||
]
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
|
@ -328,7 +352,7 @@ man_pages = [
|
|||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
(master_doc, 'CircuitPython', 'CircuitPython Documentation',
|
||||
'Damien P. George, Paul Sokolovsky, and contributors', 'CircuitPython', 'One line description of project.',
|
||||
'CircuitPython contributors', 'CircuitPython', 'Python for Microcontrollers.',
|
||||
'Miscellaneous'),
|
||||
]
|
||||
|
||||
|
@ -349,3 +373,6 @@ texinfo_documents = [
|
|||
intersphinx_mapping = {"cpython": ('https://docs.python.org/3/', None),
|
||||
"bus_device": ('https://circuitpython.readthedocs.io/projects/busdevice/en/latest/', None),
|
||||
"register": ('https://circuitpython.readthedocs.io/projects/register/en/latest/', None)}
|
||||
|
||||
def setup(app):
|
||||
app.add_css_file("customstyle.css")
|
||||
|
|
|
@ -34,10 +34,10 @@ All commands will, by default, run with `-E` (forces a rebuild from scratch of d
|
|||
|
||||
# will turn OFF the force rebuild
|
||||
make html FORCE=
|
||||
|
||||
|
||||
# will turn OFF the verbosity
|
||||
make html VERBOSE=
|
||||
|
||||
|
||||
# will turn OFF the force rebuild and make it doubly verbose when running
|
||||
make html FORCE= VERBOSE="-v -v"
|
||||
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
{% if not obj.display %}
|
||||
:orphan:
|
||||
|
||||
{% endif %}
|
||||
:mod:`{{ obj.name }}`
|
||||
======={{ "=" * obj.name|length }}
|
||||
|
||||
.. py:module:: {{ obj.name }}
|
||||
|
||||
{% if obj.docstring %}
|
||||
.. autoapi-nested-parse::
|
||||
|
||||
{{ obj.docstring|prepare_docstring|indent(3) }}
|
||||
|
||||
{% endif %}
|
||||
|
||||
{% block subpackages %}
|
||||
{% set visible_subpackages = obj.subpackages|selectattr("display")|list %}
|
||||
{% if visible_subpackages %}
|
||||
.. toctree::
|
||||
:titlesonly:
|
||||
:maxdepth: 3
|
||||
|
||||
{% for subpackage in visible_subpackages %}
|
||||
{{ subpackage.short_name }}/index.rst
|
||||
{% endfor %}
|
||||
|
||||
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
{% block submodules %}
|
||||
{% set visible_submodules = obj.submodules|selectattr("display")|list %}
|
||||
{% if visible_submodules %}
|
||||
|
||||
.. toctree::
|
||||
:titlesonly:
|
||||
:maxdepth: 1
|
||||
|
||||
{% for submodule in visible_submodules %}
|
||||
{{ submodule.short_name }}/index.rst
|
||||
{% endfor %}
|
||||
|
||||
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
{% if obj.all is not none %}
|
||||
{% set visible_children = obj.children|selectattr("short_name", "in", obj.all)|list %}
|
||||
{% elif obj.type is equalto("package") %}
|
||||
{% set visible_children = obj.children|selectattr("display")|list %}
|
||||
{% else %}
|
||||
{% set visible_children = obj.children|selectattr("display")|rejectattr("imported")|list %}
|
||||
{% endif %}
|
||||
{% if visible_children %}
|
||||
|
||||
{% set visible_classes = visible_children|selectattr("type", "equalto", "class")|list %}
|
||||
{% set visible_functions = visible_children|selectattr("type", "equalto", "function")|list %}
|
||||
{% if "show-module-summary" in autoapi_options and (visible_classes or visible_functions) %}
|
||||
{% block classes %}
|
||||
{% if visible_classes %}
|
||||
Classes
|
||||
~~~~~~~
|
||||
|
||||
.. autoapisummary::
|
||||
|
||||
{% for klass in visible_classes %}
|
||||
{{ klass.id }}
|
||||
{% endfor %}
|
||||
|
||||
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block functions %}
|
||||
{% if visible_functions %}
|
||||
Functions
|
||||
~~~~~~~~~
|
||||
|
||||
.. autoapisummary::
|
||||
|
||||
{% for function in visible_functions %}
|
||||
{{ function.id }}
|
||||
{% endfor %}
|
||||
|
||||
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
{% endif %}
|
||||
{% for obj_item in visible_children %}
|
||||
{{ obj_item.rendered|indent(0) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endblock %}
|
|
@ -1,19 +0,0 @@
|
|||
import sphinx.parsers
|
||||
|
||||
class CStrip(sphinx.parsers.Parser):
|
||||
def __init__(self):
|
||||
self.rst_parser = sphinx.parsers.RSTParser()
|
||||
|
||||
def parse(self, inputstring, document):
|
||||
# This setting is missing starting with Sphinx 1.7.1 so we set it ourself.
|
||||
document.settings.tab_width = 4
|
||||
document.settings.character_level_inline_markup = False
|
||||
stripped = []
|
||||
for line in inputstring.split("\n"):
|
||||
line = line.strip()
|
||||
if line == "//|":
|
||||
stripped.append("")
|
||||
elif line.startswith("//| "):
|
||||
stripped.append(line[len("//| "):])
|
||||
stripped = "\r\n".join(stripped)
|
||||
self.rst_parser.parse(stripped, document)
|
|
@ -60,6 +60,7 @@ For example, a user can then use ``deinit()```::
|
|||
|
||||
import digitalio
|
||||
import board
|
||||
import time
|
||||
|
||||
led = digitalio.DigitalInOut(board.D13)
|
||||
led.direction = digitalio.Direction.OUTPUT
|
||||
|
@ -79,6 +80,7 @@ Alternatively, using a ``with`` statement ensures that the hardware is deinitial
|
|||
|
||||
import digitalio
|
||||
import board
|
||||
import time
|
||||
|
||||
with digitalio.DigitalInOut(board.D13) as led:
|
||||
led.direction = digitalio.Direction.OUTPUT
|
||||
|
@ -474,6 +476,8 @@ properties.
|
|||
+-----------------------+-----------------------+-------------------------------------------------------------------------+
|
||||
| ``distance`` | float | centimeters |
|
||||
+-----------------------+-----------------------+-------------------------------------------------------------------------+
|
||||
| ``proximity`` | int | non-unit-specifc proximity values (monotonic but not actual distance) |
|
||||
+-----------------------+-----------------------+-------------------------------------------------------------------------+
|
||||
| ``light`` | float | non-unit-specific light levels (should be monotonic but is not lux) |
|
||||
+-----------------------+-----------------------+-------------------------------------------------------------------------+
|
||||
| ``lux`` | float | SI lux |
|
||||
|
@ -500,6 +504,10 @@ properties.
|
|||
+-----------------------+-----------------------+-------------------------------------------------------------------------+
|
||||
| ``value`` | int | 16-bit Analog value, unit-less |
|
||||
+-----------------------+-----------------------+-------------------------------------------------------------------------+
|
||||
| ``weight`` | float | grams (g) |
|
||||
+-----------------------+-----------------------+-------------------------------------------------------------------------+
|
||||
| ``sound_level`` | float | non-unit-specific sound level (monotonic but not actual decibels) |
|
||||
+-----------------------+-----------------------+-------------------------------------------------------------------------+
|
||||
|
||||
Adding native modules
|
||||
--------------------------------------------------------------------------------
|
||||
|
|
245
docs/drivers.rst
245
docs/drivers.rst
|
@ -1,16 +1,13 @@
|
|||
.. _adafruit-libndrivers:
|
||||
|
||||
Additional Adafruit Libraries and Drivers on GitHub
|
||||
===================================================
|
||||
Additional CircuitPython Libraries and Drivers on GitHub
|
||||
=========================================================
|
||||
|
||||
These are libraries and drivers available in separate GitHub repos. They are
|
||||
designed for use with CircuitPython and may or may not work with
|
||||
`MicroPython <https://micropython.org>`_.
|
||||
|
||||
.. _bundle_installation:
|
||||
|
||||
Bundle
|
||||
------
|
||||
Adafruit CircuitPython Library Bundle
|
||||
--------------------------------------
|
||||
|
||||
We provide a bundle of all our libraries to ease installation of drivers and
|
||||
their dependencies. The bundle is primarily geared to the Adafruit Express line
|
||||
|
@ -18,233 +15,19 @@ of boards which feature a relatively large external flash. With Express boards,
|
|||
its easy to copy them all onto the filesystem. However, if you don't have
|
||||
enough space simply copy things over as they are needed.
|
||||
|
||||
The bundles are available `on GitHub <https://github.com/adafruit/Adafruit_CircuitPython_Bundle/releases>`_.
|
||||
- The Adafruit bundles are available on GitHub: <https://github.com/adafruit/Adafruit_CircuitPython_Bundle/releases>.
|
||||
|
||||
To install them:
|
||||
- Documentation for the bundle, which includes links to documentation for all
|
||||
libraries, is available here: <https://circuitpython.readthedocs.io/projects/bundle/en/latest/>.
|
||||
|
||||
#. `Download <https://github.com/adafruit/Adafruit_CircuitPython_Bundle/releases>`_
|
||||
and unzip the latest zip that's not a source zip.
|
||||
#. Copy the ``lib`` folder to the ``CIRCUITPY`` or ``MICROPYTHON``.
|
||||
|
||||
Foundational
|
||||
------------
|
||||
CircuitPython Community Library Bundle
|
||||
---------------------------------------
|
||||
|
||||
These libraries provide critical functionality to many of the drivers below. It
|
||||
is recommended to always have them installed onto the CircuitPython file system in
|
||||
the ``lib/`` directory. Some drivers may not work without them.
|
||||
This bundle contains non-Adafruit sponsored libraries, that are written and submitted
|
||||
by members of the community.
|
||||
|
||||
.. toctree::
|
||||
- The Community bundles are available on GitHub: <https://github.com/adafruit/CircuitPython_Community_Bundle/releases>.
|
||||
|
||||
Register Library <https://circuitpython.readthedocs.io/projects/register/en/latest/>
|
||||
BusDevice Library <https://circuitpython.readthedocs.io/projects/busdevice/en/latest/>
|
||||
|
||||
Board-specific Helpers
|
||||
----------------------
|
||||
|
||||
These libraries tie lower-level libraries together to provide an easy, out-of-box experience for
|
||||
specific boards.
|
||||
|
||||
.. toctree::
|
||||
|
||||
Adafruit CircuitPlayground Express <https://circuitpython.readthedocs.io/projects/circuitplayground/en/latest/>
|
||||
Adafruit FeatherWings <https://circuitpython.readthedocs.io/projects/featherwing/en/latest/>
|
||||
|
||||
Helper Libraries
|
||||
-----------------
|
||||
|
||||
These libraries build on top of the low level APIs to simplify common tasks.
|
||||
|
||||
.. toctree::
|
||||
|
||||
USB Human Interface Device (Keyboard and Mouse) <https://circuitpython.readthedocs.io/projects/hid/en/latest/>
|
||||
Waveform Generation <https://circuitpython.readthedocs.io/projects/waveform/en/latest/>
|
||||
OneWire <https://circuitpython.readthedocs.io/projects/onewire/en/latest/>
|
||||
Ring Tone Text Transfer Language (RTTTL) <https://circuitpython.readthedocs.io/projects/rtttl/en/latest/>
|
||||
InfraRed Remote <https://circuitpython.readthedocs.io/projects/irremote/en/latest/>
|
||||
Fancy LED (similar to FastLED) <https://circuitpython.readthedocs.io/projects/fancyled/en/latest/>
|
||||
SimpleIO <https://circuitpython.readthedocs.io/projects/simpleio/en/latest/>
|
||||
AVR programming <https://circuitpython.readthedocs.io/projects/avrprog/en/latest/>
|
||||
DC Motor and Servo <https://circuitpython.readthedocs.io/projects/motor/en/latest/>
|
||||
SD Card <https://circuitpython.readthedocs.io/projects/sd/en/latest/>
|
||||
Image Load <https://circuitpython.readthedocs.io/projects/imageload/en/latest/>
|
||||
miniQR Non-hardware QR code generator <https://circuitpython.readthedocs.io/projects/miniqr/en/latest/>
|
||||
Slideshow <https://circuitpython.readthedocs.io/projects/slideshow/en/latest/>
|
||||
LED Animation <https://circuitpython.readthedocs.io/projects/led-animation/en/latest/>
|
||||
|
||||
Blinky
|
||||
--------
|
||||
|
||||
Multi-color led drivers.
|
||||
|
||||
.. toctree::
|
||||
|
||||
NeoPixel <https://circuitpython.readthedocs.io/projects/neopixel/en/latest/>
|
||||
DotStar <https://circuitpython.readthedocs.io/projects/dotstar/en/latest/>
|
||||
WS2801 <https://circuitpython.readthedocs.io/projects/ws2801/en/latest/>
|
||||
Pixie <https://circuitpython.readthedocs.io/projects/pixie/en/latest/>
|
||||
|
||||
Displays
|
||||
-------------
|
||||
|
||||
Drivers used to display information. Either pixel or segment based.
|
||||
|
||||
.. toctree::
|
||||
|
||||
RGB Displays <https://circuitpython.readthedocs.io/projects/rgb_display/en/latest/>
|
||||
Character LCD <https://circuitpython.readthedocs.io/projects/charlcd/en/latest/>
|
||||
HT16K33 LED Matrices and Segment Displays <https://circuitpython.readthedocs.io/projects/ht16k33/en/latest/>
|
||||
IS31FL3731 Charlieplexed LED Matrix <https://circuitpython.readthedocs.io/projects/is31fl3731/en/latest/>
|
||||
MAX7219 LED Matrix <https://circuitpython.readthedocs.io/projects/max7219/en/latest/>
|
||||
SSD1306 OLED Driver <https://circuitpython.readthedocs.io/projects/ssd1306/en/latest/>
|
||||
E-Paper Display <https://circuitpython.readthedocs.io/projects/epd/en/latest/>
|
||||
|
||||
Real-time clocks
|
||||
-----------------
|
||||
|
||||
Chips that keep current calendar time with a backup battery. The current date and time is available
|
||||
through ``datetime``.
|
||||
|
||||
.. toctree::
|
||||
|
||||
DS1307 Real-time Clock (5V RTC Breakout) <https://circuitpython.readthedocs.io/projects/ds1307/en/latest/>
|
||||
DS3231 Real-time Clock (Precision RTC) <https://circuitpython.readthedocs.io/projects/ds3231/en/latest/>
|
||||
PCF8523 Real-time Clock (Adalogger RTC) <https://circuitpython.readthedocs.io/projects/pcf8523/en/latest/>
|
||||
|
||||
Motion Sensors
|
||||
----------------
|
||||
|
||||
Motion relating sensing including ``acceleration``, ``magnetic``, ``gyro``, and ``orientation``.
|
||||
|
||||
.. toctree::
|
||||
|
||||
ADXL34x 3 Axis Accelerometer <https://circuitpython.readthedocs.io/projects/adxl34x/en/latest/>
|
||||
BNO055 Accelerometer, Magnetometer, Gyroscope and Absolution Orientation <https://circuitpython.readthedocs.io/projects/bno055/en/latest/>
|
||||
FXAS21002C Gyroscope <https://circuitpython.readthedocs.io/projects/fxas21002c/en/latest/>
|
||||
FXOS8700 Accelerometer <https://circuitpython.readthedocs.io/projects/fxos8700/en/latest/>
|
||||
GPS Global Position <https://circuitpython.readthedocs.io/projects/gps/en/latest/>
|
||||
L3GD20 Gyroscope <https://circuitpython.readthedocs.io/projects/l3gd20/latest/>
|
||||
LIS3DH Accelerometer <https://circuitpython.readthedocs.io/projects/lis3dh/en/latest/>
|
||||
LSM303 Accelerometer and Magnetometer <https://circuitpython.readthedocs.io/projects/lsm303/en/latest/>
|
||||
LSM9DS0 Accelerometer, Magnetometer, Gyroscope and Temperature <https://circuitpython.readthedocs.io/projects/lsm9ds0/en/latest/>
|
||||
LSM9DS1 Accelerometer, Magnetometer, Gyroscope and Temperature <https://circuitpython.readthedocs.io/projects/lsm9ds1/en/latest/>
|
||||
MLX90390 3 Axis Mangetometer <https://circuitpython.readthedocs.io/projects/mlx90393/en/latest/>
|
||||
MMA8451 3 axis accelerometer <https://circuitpython.readthedocs.io/projects/mma8451/en/latest/>
|
||||
|
||||
Environmental Sensors
|
||||
----------------------
|
||||
|
||||
Sense attributes of the environment including ``temperature``, ``relative_humidity``, ``pressure``,
|
||||
equivalent carbon dioxide (``eco2`` / ``eCO2``), and total volatile organic compounds (``tvoc`` /
|
||||
``TVOC``).
|
||||
|
||||
.. toctree::
|
||||
|
||||
AM2320 Temperature and Humidity <https://circuitpython.readthedocs.io/projects/am2320/en/latest/>
|
||||
BME280 Temperature, Humidity and Pressure <https://circuitpython.readthedocs.io/projects/bme280/en/latest/>
|
||||
BME680 Temperature, Humidity, Pressure and Gas <https://circuitpython.readthedocs.io/projects/bme680/en/latest/>
|
||||
BMP280 Barometric Pressure and Altitude <https://circuitpython.readthedocs.io/projects/bmp280/en/latest/>
|
||||
BMP3xx Barometric Pressure and Altimeter <https://circuitpython.readthedocs.io/projects/bmp3xx/en/latest/>
|
||||
CCS811 Air Quality <https://circuitpython.readthedocs.io/projects/ccs811/en/latest/>
|
||||
DHT Temperature and Humidity <https://circuitpython.readthedocs.io/projects/dht/en/latest/>
|
||||
DS18x20 Temperature <https://circuitpython.readthedocs.io/projects/ds18x20/en/latest/>
|
||||
HTU21D Temperature and Humidity <https://circuitpython.readthedocs.io/projects/htu21d/en/latest/>
|
||||
MAX31865 Thermocouple Amplifier, Temperature <https://circuitpython.readthedocs.io/projects/max31865/en/latest/>
|
||||
MAX31855 Thermocouple Amplifier, Temperature <https://circuitpython.readthedocs.io/projects/max31855/en/latest/>
|
||||
MAX31856 Thermocouple Amplifier, Temperature <https://circuitpython.readthedocs.io/projects/max31856/en/latest/>
|
||||
MCP9808 Temperature <https://circuitpython.readthedocs.io/projects/mcp9808/en/latest/>
|
||||
MP115A2 Barometric Pressure, Temperature <https://circuitpython.readthedocs.io/projects/mpl115a2/en/latest/>
|
||||
MPL3115A2 Barometric Pressure, Altitude and Temperature Sensor <https://circuitpython.readthedocs.io/projects/mpl3115a2/en/latest/>
|
||||
MPRLS Ported Absolute Pressure <https://circuitpython.readthedocs.io/projects/mprls/en/latest/>
|
||||
SGP30 Air Quality <https://circuitpython.readthedocs.io/projects/sgp30/en/latest/>
|
||||
SHT31-D Temperature and Humidity <https://circuitpython.readthedocs.io/projects/sht31d/en/latest/>
|
||||
Si7021 Temperature and Humidity <https://circuitpython.readthedocs.io/projects/si7021/en/latest/>
|
||||
Thermistor Temperature <https://circuitpython.readthedocs.io/projects/thermistor/en/latest/>
|
||||
TMP007 Contactless Temperature <https://circuitpython.readthedocs.io/projects/tmp007/en/latest/>
|
||||
MLX90614 Contactless Temperature <https://circuitpython.readthedocs.io/projects/mlx90614/en/latest/>
|
||||
|
||||
Light Sensors
|
||||
---------------
|
||||
|
||||
These sensors detect light related attributes such as ``color``, ``light`` (unit-less), and
|
||||
``lux`` (light in SI lux).
|
||||
|
||||
.. toctree::
|
||||
|
||||
APDS9960 Proximity, Light, RGB, and Gesture <https://circuitpython.readthedocs.io/projects/apds9960/en/latest/>
|
||||
AS726x Color Spectrum Sensor <https://circuitpython.readthedocs.io/projects/as726x/en/latest/>
|
||||
TCS34725 Color Sensor <https://circuitpython.readthedocs.io/projects/tcs34725/en/latest/>
|
||||
TSL2561 Light Sensor <https://circuitpython.readthedocs.io/projects/tsl2561/en/latest/>
|
||||
TSL2591 High Dynamic Range Light Sensor <https://circuitpython.readthedocs.io/projects/tsl2591/en/latest/>
|
||||
VCNL4010 Proximity and Light <https://circuitpython.readthedocs.io/projects/vcnl4010/en/latest/>
|
||||
VEML6070 UV Index <https://circuitpython.readthedocs.io/projects/veml6070/en/latest/>
|
||||
VEML6075 UV Index <https://circuitpython.readthedocs.io/projects/veml6075/en/latest/>
|
||||
|
||||
Distance Sensors
|
||||
------------------
|
||||
|
||||
These sensors measure the ``distance`` to another object and may also measure light level (``light`` and ``lux``).
|
||||
|
||||
.. toctree::
|
||||
|
||||
Garmin LIDARLite I2C <https://circuitpython.readthedocs.io/projects/lidarlite/en/latest/>
|
||||
TFmini IR Time of Flight ~30cm - 12m <https://circuitpython.readthedocs.io/projects/tfmini/en/latest/>
|
||||
VL6180x 5 - 100 mm <https://circuitpython.readthedocs.io/projects/vl6180x/en/latest/>
|
||||
VL53L0x ~30 - 1000 mm <https://circuitpython.readthedocs.io/projects/vl53l0x/en/latest/>
|
||||
HC-SR04 Ultrasonic Range Sensors <https://circuitpython.readthedocs.io/projects/hcsr04/en/latest/>
|
||||
|
||||
Radio
|
||||
--------
|
||||
|
||||
These chips communicate to other's over radio.
|
||||
|
||||
.. toctree::
|
||||
|
||||
Adafruit Bluefruit LE SPI Friend <https://circuitpython.readthedocs.io/projects/bluefruitspi/en/latest/>
|
||||
RFM9x LoRa <https://circuitpython.readthedocs.io/projects/rfm9x/en/latest/>
|
||||
RFM69 Packet Radio <https://circuitpython.readthedocs.io/projects/rfm69/en/latest/>
|
||||
PN532 NFC/RFID <https://circuitpython.readthedocs.io/projects/pn532/en/latest/>
|
||||
|
||||
IO Expansion
|
||||
--------------
|
||||
|
||||
These provide functionality similar to `analogio`, `digitalio`, `pulseio`, and `touchio`.
|
||||
|
||||
.. toctree::
|
||||
|
||||
Adafruit SeeSaw <https://circuitpython.readthedocs.io/projects/seesaw/en/latest/>
|
||||
ADS1x15 Analog-to-Digital Converter <https://circuitpython.readthedocs.io/projects/ads1x15/en/latest/>
|
||||
Crickit Robotics Boards <<https://circuitpython.readthedocs.io/projects/crickit/en/latest/>
|
||||
DS2413 OneWire GPIO Expander <https://circuitpython.readthedocs.io/projects/ds2413/en/latest/>
|
||||
FocalTech Capacitive Touch <https://circuitpython.readthedocs.io/projects/focaltouch/en/latest/>
|
||||
MCP230xx GPIO Expander <https://circuitpython.readthedocs.io/projects/mcp230xx/en/latest/>
|
||||
MCP4725 Digital-to-Analog Converter <https://circuitpython.readthedocs.io/projects/mcp4725/en/latest/>
|
||||
PCA9685 16 x 12-bit PWM Driver <https://circuitpython.readthedocs.io/projects/pca9685/en/latest/>
|
||||
TLC5947 24 x 12-bit PWM Driver <https://circuitpython.readthedocs.io/projects/tlc5947/en/latest/>
|
||||
TLC59711 12 x 16-bit PWM Driver <https://circuitpython.readthedocs.io/projects/tlc59711/en/latest/>
|
||||
MPR121 Capacitive Touch Sensor <https://circuitpython.readthedocs.io/projects/mpr121/en/latest/>
|
||||
TCA9548 I2C Multiplexer <https://circuitpython.readthedocs.io/projects/tca9548a/en/latest/>
|
||||
MCP3xxx SPI ADC <https://circuitpython.readthedocs.io/projects/mcp3xxx/en/latest/>
|
||||
|
||||
Miscellaneous
|
||||
----------------
|
||||
|
||||
.. toctree::
|
||||
|
||||
CAP1188 8-Key Capacitive Touch <https://circuitpython.readthedocs.io/projects/cap1188/en/latest/>
|
||||
Si4713 Stereo FM Transmitter <https://circuitpython.readthedocs.io/projects/si4713/en/latest/>
|
||||
AMG88xx Grid-Eye IR Camera <https://circuitpython.readthedocs.io/projects/amg88xx/en/latest/>
|
||||
Trellis 4x4 Keypad <https://circuitpython.readthedocs.io/projects/trellis/en/latest/>
|
||||
NeoTrellis 4x4 Keypad <https://circuitpython.readthedocs.io/projects/neotrellis/en/latest/>
|
||||
NeoTrellis M4 4x8 Keypad <https://circuitpython.readthedocs.io/projects/trellism4/en/latest/>
|
||||
DRV2605 Haptic Motor Controller <https://circuitpython.readthedocs.io/projects/drv2605/en/latest/>
|
||||
MAX9744 Audio Amplifier <https://circuitpython.readthedocs.io/projects/max9744/en/latest/>
|
||||
Si5351 Clock Generator <https://circuitpython.readthedocs.io/projects/si5351/en/latest/>
|
||||
Thermal Printer <https://circuitpython.readthedocs.io/projects/thermal_printer/en/latest/>
|
||||
VC0706 TTL Camera <https://circuitpython.readthedocs.io/projects/vc0706/en/latest/>
|
||||
INA219 High Side Current <https://circuitpython.readthedocs.io/projects/ina219/en/latest/>
|
||||
Fingerprint <https://circuitpython.readthedocs.io/projects/fingerprint/en/latest/>
|
||||
STMPE610 Resistive Touchscreen <https://circuitpython.readthedocs.io/projects/stmpe610/en/latest/>
|
||||
Matrix Keypad <https://circuitpython.readthedocs.io/projects/matrixkeypad/en/latest/>
|
||||
VS1053 Audio Codec <https://circuitpython.readthedocs.io/projects/vs1053/en/latest/>
|
||||
FRAM Non-Volatile Memory <https://circuitpython.readthedocs.io/projects/fram/en/latest/>
|
||||
74HC595 Shift Register <https://circuitpython.readthedocs.io/projects/74hc595/en/latest/>
|
||||
- Documentation is not available on ReadTheDocs at this time. See each library for any
|
||||
included documentation.
|
||||
|
|
|
@ -43,6 +43,7 @@ Full Table of Contents
|
|||
|
||||
../README
|
||||
../CONTRIBUTING
|
||||
../BUILDING
|
||||
../CODE_OF_CONDUCT
|
||||
../license.rst
|
||||
|
||||
|
|
|
@ -78,12 +78,12 @@ Not all of these functions and types are turned on in all CircuitPython ports, f
|
|||
|
||||
.. classmethod:: from_bytes(bytes, byteorder)
|
||||
|
||||
In CircuitPython, `byteorder` parameter must be positional (this is
|
||||
In CircuitPython, ``byteorder`` parameter must be positional (this is
|
||||
compatible with CPython).
|
||||
|
||||
.. method:: to_bytes(size, byteorder)
|
||||
|
||||
In CircuitPython, `byteorder` parameter must be positional (this is
|
||||
In CircuitPython, ``byteorder`` parameter must be positional (this is
|
||||
compatible with CPython).
|
||||
|
||||
.. function:: isinstance()
|
||||
|
@ -182,7 +182,7 @@ Exceptions
|
|||
|
||||
.. exception:: OSError
|
||||
|
||||
|see_cpython| `OSError`. CircuitPython doesn't implement the ``errno``
|
||||
|see_cpython| :py:class:`cpython:OSError`. CircuitPython doesn't implement the ``errno``
|
||||
attribute, instead use the standard way to access exception arguments:
|
||||
``exc.args[0]``.
|
||||
|
||||
|
@ -198,11 +198,11 @@ Exceptions
|
|||
|
||||
.. exception:: SystemExit
|
||||
|
||||
|see_cpython| :py:class:`python:SystemExit`.
|
||||
|see_cpython| :py:class:`cpython:SystemExit`.
|
||||
|
||||
.. exception:: TypeError
|
||||
|
||||
|see_cpython| :py:class:`python:TypeError`.
|
||||
|see_cpython| :py:class:`cpython:TypeError`.
|
||||
|
||||
.. exception:: ValueError
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
.. include:: ../templates/unsupported_in_circuitpython.inc
|
||||
|
||||
.. module:: network
|
||||
:noindex:
|
||||
:synopsis: network configuration
|
||||
|
||||
This module provides network drivers and routing configuration. To use this
|
||||
|
@ -246,7 +247,7 @@ Methods
|
|||
nic.ifconfig(('192.168.0.4', '255.255.255.0', '192.168.0.1', '8.8.8.8'))
|
||||
|
||||
.. method:: wlan.config('param')
|
||||
.. method:: wlan.config(param=value, ...)
|
||||
wlan.config(param=value, ...)
|
||||
|
||||
Get or set general network interface parameters. These methods allow to work
|
||||
with additional parameters beyond standard IP configuration (as dealt with by
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
We love CircuitPython and would love to see it come to more microcontroller
|
||||
platforms. With 3.0 we've reworked CircuitPython to make it easier than ever to
|
||||
platforms. Since 3.0 we've reworked CircuitPython to make it easier than ever to
|
||||
add support. While there are some major differences between ports, this page
|
||||
covers the similarities that make CircuitPython what it is and how that core
|
||||
fits into a variety of microcontrollers.
|
||||
|
@ -19,7 +19,7 @@ prepping file systems and automatically running user code on boot. In
|
|||
CircuitPython we've dubbed this component the supervisor because it monitors
|
||||
and facilitates the VMs which run user Python code. Porting involves the
|
||||
supervisor because many of the tasks it does while interfacing with the
|
||||
hardware. Once its going though, the REPL works and debugging can migrate to a
|
||||
hardware. Once complete, the REPL works and debugging can migrate to a
|
||||
Python based approach rather than C.
|
||||
|
||||
The third core piece is the plethora of low level APIs that CircuitPython
|
||||
|
@ -42,6 +42,44 @@ to the port's directory (in the top level until the ``ports`` directory is
|
|||
present). This includes the Makefile and any C library resources. Make sure
|
||||
these resources are compatible with the MIT License of the rest of the code!
|
||||
|
||||
Circuitpython has a number of modules enabled by default in
|
||||
``py/circuitpy_mpconfig.mk``. Most of these modules will need to be disabled in
|
||||
``mpconfigboard.mk`` during the early stages of a port in order for it to
|
||||
compile. As the port progresses in module support, this list can be pruned down
|
||||
as a natural "TODO" list. An example minimal build list is shown below:
|
||||
|
||||
.. code-block:: makefile
|
||||
|
||||
# These modules are implemented in ports/<port>/common-hal:
|
||||
CIRCUITPY_MICROCONTROLLER = 0 # Typically the first module to create
|
||||
CIRCUITPY_DIGITALIO = 0 # Typically the second module to create
|
||||
CIRCUITPY_ANALOGIO = 0
|
||||
CIRCUITPY_BUSIO = 0
|
||||
CIRCUITPY_NEOPIXEL_WRITE = 0
|
||||
CIRCUITPY_PULSEIO = 0
|
||||
CIRCUITPY_OS = 0
|
||||
CIRCUITPY_NVM = 0
|
||||
CIRCUITPY_AUDIOBUSIO = 0
|
||||
CIRCUITPY_AUDIOIO = 0
|
||||
CIRCUITPY_ROTARYIO = 0
|
||||
CIRCUITPY_RTC = 0
|
||||
CIRCUITPY_FREQUENCYIO = 0
|
||||
CIRCUITPY_I2CSLAVE = 0
|
||||
CIRCUITPY_DISPLAYIO = 0 # Requires SPI, PulseIO (stub ok)
|
||||
|
||||
# These modules are implemented in shared-module/ - they can be included in
|
||||
# any port once their prerequisites in common-hal are complete.
|
||||
CIRCUITPY_BITBANGIO = 0 # Requires DigitalIO
|
||||
CIRCUITPY_GAMEPAD = 0 # Requires DigitalIO
|
||||
CIRCUITPY_PIXELBUF = 0 # Requires neopixel_write or SPI (dotstar)
|
||||
CIRCUITPY_RANDOM = 0 # Requires OS
|
||||
CIRCUITPY_STORAGE = 0 # Requires OS, filesystem
|
||||
CIRCUITPY_TOUCHIO = 0 # Requires Microcontroller
|
||||
CIRCUITPY_USB_HID = 0 # Requires USB
|
||||
CIRCUITPY_USB_MIDI = 0 # Requires USB
|
||||
CIRCUITPY_REQUIRE_I2C_PULLUPS = 0 # Does nothing without I2C
|
||||
CIRCUITPY_ULAB = 0 # No requirements, but takes extra flash
|
||||
|
||||
Step 2: Init
|
||||
--------------
|
||||
Once your build is setup, the next step should be to get your clocks going as
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
sphinx<3
|
||||
recommonmark==0.6.0
|
||||
sphinxcontrib-svg2pdfconverter==0.1.0
|
||||
astroid
|
||||
sphinx-autoapi
|
|
@ -0,0 +1,24 @@
|
|||
# Derived from code on Eric Holscher's blog, found at:
|
||||
# https://www.ericholscher.com/blog/2016/jul/25/integrating-jinja-rst-sphinx/
|
||||
|
||||
def rstjinja(app, docname, source):
|
||||
"""
|
||||
Render our pages as a jinja template for fancy templating goodness.
|
||||
"""
|
||||
# Make sure we're outputting HTML
|
||||
if app.builder.format != 'html':
|
||||
return
|
||||
|
||||
# we only want our one jinja template to run through this func
|
||||
if "shared-bindings/support_matrix" not in docname:
|
||||
return
|
||||
|
||||
src = source[0]
|
||||
print(docname)
|
||||
rendered = app.builder.templates.render_string(
|
||||
src, app.config.html_context
|
||||
)
|
||||
source[0] = rendered
|
||||
|
||||
def setup(app):
|
||||
app.connect("source-read", rstjinja)
|
|
@ -0,0 +1,158 @@
|
|||
# The MIT License (MIT)
|
||||
#
|
||||
# Copyright (c) 2019 Michael Schroeder
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE.
|
||||
#
|
||||
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
SUPPORTED_PORTS = ['atmel-samd', 'esp32s2', 'litex', 'mimxrt10xx', 'nrf', 'stm']
|
||||
|
||||
def get_shared_bindings():
|
||||
""" Get a list of modules in shared-bindings based on folder names
|
||||
"""
|
||||
return [item for item in os.listdir("./shared-bindings")]
|
||||
|
||||
|
||||
def read_mpconfig():
|
||||
""" Open 'circuitpy_mpconfig.mk' and return the contents.
|
||||
"""
|
||||
configs = []
|
||||
with open("py/circuitpy_mpconfig.mk") as mpconfig:
|
||||
configs = mpconfig.read()
|
||||
|
||||
return configs
|
||||
|
||||
|
||||
def build_module_map():
|
||||
""" Establish the base of the JSON file, based on the contents from
|
||||
`configs`. Base will contain module names, if they're part of
|
||||
the `FULL_BUILD`, or their default value (0, 1, or a list of
|
||||
modules that determine default [see audiocore, audiomixer, etc.]).
|
||||
|
||||
"""
|
||||
base = dict()
|
||||
modules = get_shared_bindings()
|
||||
configs = read_mpconfig()
|
||||
full_build = False
|
||||
for module in modules:
|
||||
full_name = module
|
||||
search_name = module.lstrip("_")
|
||||
re_pattern = "CIRCUITPY_{}\s*\??=\s*(.+)".format(search_name.upper())
|
||||
find_config = re.findall(re_pattern, configs)
|
||||
if not find_config:
|
||||
continue
|
||||
find_config = ", ".join([x.strip("$()") for x in find_config])
|
||||
|
||||
full_build = int("CIRCUITPY_FULL_BUILD" in find_config)
|
||||
if not full_build:
|
||||
default_val = find_config
|
||||
else:
|
||||
default_val = "None"
|
||||
|
||||
base[search_name] = {
|
||||
"name": full_name,
|
||||
"full_build": str(full_build),
|
||||
"default_value": default_val,
|
||||
"excluded": {}
|
||||
}
|
||||
|
||||
return base
|
||||
|
||||
def get_settings_from_makefile(port_dir, board_name):
|
||||
""" Invoke make in a mode which prints the database, then parse it for
|
||||
settings.
|
||||
|
||||
This means that the effect of all Makefile directives is taken
|
||||
into account, without having to re-encode the logic that sets them
|
||||
in this script, something that has proved error-prone
|
||||
"""
|
||||
contents = subprocess.run(
|
||||
["make", "-C", port_dir, f"BOARD={board_name}", "-qp", "print-CC"],
|
||||
encoding="utf-8",
|
||||
errors="replace",
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE
|
||||
)
|
||||
# Make signals errors with exit status 2; 0 and 1 are "non-error" statuses
|
||||
if contents.returncode not in (0, 1):
|
||||
error_msg = (
|
||||
f"Invoking '{' '.join(contents.args)}' exited with "
|
||||
f"{contents.returncode}: {contents.stderr}"
|
||||
)
|
||||
raise RuntimeError(error_msg)
|
||||
|
||||
settings = {}
|
||||
for line in contents.stdout.split('\n'):
|
||||
m = re.match(r'^([A-Z][A-Z0-9_]*) = (.*)$', line)
|
||||
if m:
|
||||
settings[m.group(1)] = m.group(2)
|
||||
|
||||
return settings
|
||||
|
||||
def lookup_setting(settings, key, default=''):
|
||||
while True:
|
||||
value = settings.get(key, default)
|
||||
if not value.startswith('$'):
|
||||
break
|
||||
key = value[2:-1]
|
||||
return value
|
||||
|
||||
def support_matrix_by_board():
|
||||
""" Compiles a list of the available core modules available for each
|
||||
board.
|
||||
"""
|
||||
base = build_module_map()
|
||||
|
||||
boards = dict()
|
||||
for port in SUPPORTED_PORTS:
|
||||
|
||||
port_dir = "ports/{}/boards".format(port)
|
||||
for entry in os.scandir(port_dir):
|
||||
if not entry.is_dir():
|
||||
continue
|
||||
board_modules = []
|
||||
|
||||
settings = get_settings_from_makefile(f'ports/{port}', entry.name)
|
||||
|
||||
with open(os.path.join(entry.path, "mpconfigboard.h")) as get_name:
|
||||
board_contents = get_name.read()
|
||||
board_name_re = re.search("(?<=MICROPY_HW_BOARD_NAME)\s+(.+)",
|
||||
board_contents)
|
||||
if board_name_re:
|
||||
board_name = board_name_re.group(1).strip('"')
|
||||
|
||||
board_modules = []
|
||||
for module in base:
|
||||
key = f'CIRCUITPY_{module.upper()}'
|
||||
if int(lookup_setting(settings, key, '0')):
|
||||
board_modules.append(base[module]['name'])
|
||||
boards[board_name] = sorted(board_modules)
|
||||
|
||||
#print(json.dumps(boards, indent=2))
|
||||
return boards
|
||||
|
||||
if __name__ == '__main__':
|
||||
print(json.dumps(support_matrix_by_board(), indent=2))
|
|
@ -1,12 +1,19 @@
|
|||
Supported Ports
|
||||
==============================
|
||||
|
||||
Adafruit's CircuitPython currently has limited support with a focus on supporting the Atmel SAMD
|
||||
and ESP8266.
|
||||
CircuitPython supports a number of microcontroller families. Support quality for each varies
|
||||
depending on the active contributors for each port.
|
||||
|
||||
Adafruit sponsored developers are actively contributing to atmel-samd, mimxrt10xx, nrf and stm
|
||||
ports. They also maintain the other ports in order to ensure the boards build. Additional testing
|
||||
is limited.
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
../ports/atmel-samd/README
|
||||
../ports/esp8266/README
|
||||
../ports/cxd56/README
|
||||
../ports/litex/README
|
||||
../ports/mimxrt10xx/README
|
||||
../ports/nrf/README
|
||||
../ports/stm/README
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
//
|
||||
//! \file socket.c
|
||||
//! \brief SOCKET APIs Implements file.
|
||||
//! \details SOCKET APIs like as Berkeley Socket APIs.
|
||||
//! \details SOCKET APIs like as Berkeley Socket APIs.
|
||||
//! \version 1.0.3
|
||||
//! \date 2013/10/21
|
||||
//! \par Revision history
|
||||
|
@ -10,7 +10,7 @@
|
|||
//! <2014/05/01> V1.0.3. Refer to M20140501
|
||||
//! 1. Implicit type casting -> Explicit type casting.
|
||||
//! 2. replace 0x01 with PACK_REMAINED in recvfrom()
|
||||
//! 3. Validation a destination ip in connect() & sendto():
|
||||
//! 3. Validation a destination ip in connect() & sendto():
|
||||
//! It occurs a fatal error on converting unint32 address if uint8* addr parameter is not aligned by 4byte address.
|
||||
//! Copy 4 byte addr value into temporary uint32 variable and then compares it.
|
||||
//! <2013/12/20> V1.0.2 Refer to M20131220
|
||||
|
@ -23,30 +23,30 @@
|
|||
//!
|
||||
//! Copyright (c) 2013, WIZnet Co., LTD.
|
||||
//! All rights reserved.
|
||||
//!
|
||||
//! Redistribution and use in source and binary forms, with or without
|
||||
//! modification, are permitted provided that the following conditions
|
||||
//! are met:
|
||||
//!
|
||||
//! * Redistributions of source code must retain the above copyright
|
||||
//! notice, this list of conditions and the following disclaimer.
|
||||
//!
|
||||
//! Redistribution and use in source and binary forms, with or without
|
||||
//! modification, are permitted provided that the following conditions
|
||||
//! are met:
|
||||
//!
|
||||
//! * Redistributions of source code must retain the above copyright
|
||||
//! notice, this list of conditions and the following disclaimer.
|
||||
//! * Redistributions in binary form must reproduce the above copyright
|
||||
//! notice, this list of conditions and the following disclaimer in the
|
||||
//! documentation and/or other materials provided with the distribution.
|
||||
//! * Neither the name of the <ORGANIZATION> nor the names of its
|
||||
//! contributors may be used to endorse or promote products derived
|
||||
//! from this software without specific prior written permission.
|
||||
//!
|
||||
//! documentation and/or other materials provided with the distribution.
|
||||
//! * Neither the name of the <ORGANIZATION> nor the names of its
|
||||
//! contributors may be used to endorse or promote products derived
|
||||
//! from this software without specific prior written permission.
|
||||
//!
|
||||
//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
//! AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
//! AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
//! IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
//! ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
//! LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
//! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
//! ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
//! LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
//! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
//! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
//! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
//! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
//! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
//! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
//! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
//! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
//! THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
@ -123,7 +123,7 @@ int8_t WIZCHIP_EXPORT(socket)(uint8_t sn, uint8_t protocol, uint16_t port, uint8
|
|||
#if _WIZCHIP_ == 5200
|
||||
if(flag & 0x10) return SOCKERR_SOCKFLAG;
|
||||
#endif
|
||||
|
||||
|
||||
if(flag != 0)
|
||||
{
|
||||
switch(protocol)
|
||||
|
@ -154,7 +154,7 @@ int8_t WIZCHIP_EXPORT(socket)(uint8_t sn, uint8_t protocol, uint16_t port, uint8
|
|||
port = sock_any_port++;
|
||||
if(sock_any_port == 0xFFF0) sock_any_port = SOCK_ANY_PORT_NUM;
|
||||
}
|
||||
setSn_PORT(sn,port);
|
||||
setSn_PORT(sn,port);
|
||||
setSn_CR(sn,Sn_CR_OPEN);
|
||||
while(getSn_CR(sn));
|
||||
sock_io_mode |= ((flag & SF_IO_NONBLOCK) << sn);
|
||||
|
@ -163,12 +163,12 @@ int8_t WIZCHIP_EXPORT(socket)(uint8_t sn, uint8_t protocol, uint16_t port, uint8
|
|||
sock_pack_info[sn] = 0;
|
||||
while(getSn_SR(sn) == SOCK_CLOSED);
|
||||
return (int8_t)sn;
|
||||
}
|
||||
}
|
||||
|
||||
int8_t WIZCHIP_EXPORT(close)(uint8_t sn)
|
||||
{
|
||||
CHECK_SOCKNUM();
|
||||
|
||||
|
||||
setSn_CR(sn,Sn_CR_CLOSE);
|
||||
/* wait to process the command... */
|
||||
while( getSn_CR(sn) );
|
||||
|
@ -216,18 +216,18 @@ int8_t WIZCHIP_EXPORT(connect)(uint8_t sn, uint8_t * addr, uint16_t port)
|
|||
if (taddr == 0xFFFFFFFF || taddr == 0) return SOCKERR_IPINVALID;
|
||||
}
|
||||
//
|
||||
|
||||
|
||||
if(port == 0) return SOCKERR_PORTZERO;
|
||||
setSn_DIPR(sn,addr);
|
||||
setSn_DPORT(sn,port);
|
||||
#if _WIZCHIP_ == 5200 // for W5200 ARP errata
|
||||
#if _WIZCHIP_ == 5200 // for W5200 ARP errata
|
||||
setSUBR(wizchip_getsubn());
|
||||
#endif
|
||||
setSn_CR(sn,Sn_CR_CONNECT);
|
||||
while(getSn_CR(sn));
|
||||
if(sock_io_mode & (1<<sn)) return SOCK_BUSY;
|
||||
while(getSn_SR(sn) != SOCK_ESTABLISHED)
|
||||
{
|
||||
{
|
||||
if (getSn_SR(sn) == SOCK_CLOSED) {
|
||||
#if _WIZCHIP_ == 5200 // for W5200 ARP errata
|
||||
setSUBR((uint8_t*)"\x00\x00\x00\x00");
|
||||
|
@ -237,17 +237,17 @@ int8_t WIZCHIP_EXPORT(connect)(uint8_t sn, uint8_t * addr, uint16_t port)
|
|||
if (getSn_IR(sn) & Sn_IR_TIMEOUT)
|
||||
{
|
||||
setSn_IR(sn, Sn_IR_TIMEOUT);
|
||||
#if _WIZCHIP_ == 5200 // for W5200 ARP errata
|
||||
#if _WIZCHIP_ == 5200 // for W5200 ARP errata
|
||||
setSUBR((uint8_t*)"\x00\x00\x00\x00");
|
||||
#endif
|
||||
return SOCKERR_TIMEOUT;
|
||||
}
|
||||
MICROPY_THREAD_YIELD();
|
||||
}
|
||||
#if _WIZCHIP_ == 5200 // for W5200 ARP errata
|
||||
#if _WIZCHIP_ == 5200 // for W5200 ARP errata
|
||||
setSUBR((uint8_t*)"\x00\x00\x00\x00");
|
||||
#endif
|
||||
|
||||
|
||||
return SOCK_OK;
|
||||
}
|
||||
|
||||
|
@ -275,7 +275,7 @@ int32_t WIZCHIP_EXPORT(send)(uint8_t sn, uint8_t * buf, uint16_t len)
|
|||
{
|
||||
uint8_t tmp=0;
|
||||
uint16_t freesize=0;
|
||||
|
||||
|
||||
CHECK_SOCKNUM();
|
||||
CHECK_SOCKMODE(Sn_MR_TCP);
|
||||
CHECK_SOCKDATA();
|
||||
|
@ -295,7 +295,7 @@ int32_t WIZCHIP_EXPORT(send)(uint8_t sn, uint8_t * buf, uint16_t len)
|
|||
return SOCKERR_BUSY;
|
||||
}
|
||||
#endif
|
||||
sock_is_sending &= ~(1<<sn);
|
||||
sock_is_sending &= ~(1<<sn);
|
||||
}
|
||||
else if(tmp & Sn_IR_TIMEOUT)
|
||||
{
|
||||
|
@ -338,7 +338,7 @@ int32_t WIZCHIP_EXPORT(recv)(uint8_t sn, uint8_t * buf, uint16_t len)
|
|||
CHECK_SOCKNUM();
|
||||
CHECK_SOCKMODE(Sn_MR_TCP);
|
||||
CHECK_SOCKDATA();
|
||||
|
||||
|
||||
recvsize = getSn_RxMAX(sn);
|
||||
if(recvsize < len) len = recvsize;
|
||||
while(1)
|
||||
|
@ -398,9 +398,9 @@ int32_t WIZCHIP_EXPORT(sendto)(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t
|
|||
if(port == 0) return SOCKERR_PORTZERO;
|
||||
tmp = getSn_SR(sn);
|
||||
if(tmp != SOCK_MACRAW && tmp != SOCK_UDP) return SOCKERR_SOCKSTATUS;
|
||||
|
||||
|
||||
setSn_DIPR(sn,addr);
|
||||
setSn_DPORT(sn,port);
|
||||
setSn_DPORT(sn,port);
|
||||
freesize = getSn_TxMAX(sn);
|
||||
if (len > freesize) len = freesize; // check size not to exceed MAX size.
|
||||
while(1)
|
||||
|
@ -413,7 +413,7 @@ int32_t WIZCHIP_EXPORT(sendto)(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t
|
|||
};
|
||||
wiz_send_data(sn, buf, len);
|
||||
|
||||
#if _WIZCHIP_ == 5200 // for W5200 ARP errata
|
||||
#if _WIZCHIP_ == 5200 // for W5200 ARP errata
|
||||
setSUBR(wizchip_getsubn());
|
||||
#endif
|
||||
|
||||
|
@ -433,7 +433,7 @@ int32_t WIZCHIP_EXPORT(sendto)(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t
|
|||
else if(tmp & Sn_IR_TIMEOUT)
|
||||
{
|
||||
setSn_IR(sn, Sn_IR_TIMEOUT);
|
||||
#if _WIZCHIP_ == 5200 // for W5200 ARP errata
|
||||
#if _WIZCHIP_ == 5200 // for W5200 ARP errata
|
||||
setSUBR((uint8_t*)"\x00\x00\x00\x00");
|
||||
#endif
|
||||
return SOCKERR_TIMEOUT;
|
||||
|
@ -441,7 +441,7 @@ int32_t WIZCHIP_EXPORT(sendto)(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t
|
|||
////////////
|
||||
MICROPY_THREAD_YIELD();
|
||||
}
|
||||
#if _WIZCHIP_ == 5200 // for W5200 ARP errata
|
||||
#if _WIZCHIP_ == 5200 // for W5200 ARP errata
|
||||
setSUBR((uint8_t*)"\x00\x00\x00\x00");
|
||||
#endif
|
||||
return len;
|
||||
|
@ -462,7 +462,7 @@ int32_t WIZCHIP_EXPORT(recvfrom)(uint8_t sn, uint8_t * buf, uint16_t len, uint8_
|
|||
case Sn_MR_UDP:
|
||||
case Sn_MR_MACRAW:
|
||||
break;
|
||||
#if ( _WIZCHIP_ < 5200 )
|
||||
#if ( _WIZCHIP_ < 5200 )
|
||||
case Sn_MR_IPRAW:
|
||||
case Sn_MR_PPPoE:
|
||||
break;
|
||||
|
@ -519,7 +519,7 @@ int32_t WIZCHIP_EXPORT(recvfrom)(uint8_t sn, uint8_t * buf, uint16_t len, uint8_
|
|||
sock_remained_size[sn] = head[0];
|
||||
sock_remained_size[sn] = (sock_remained_size[sn] <<8) + head[1];
|
||||
sock_remained_size[sn] -= 2; // len includes 2 len bytes
|
||||
if(sock_remained_size[sn] > 1514)
|
||||
if(sock_remained_size[sn] > 1514)
|
||||
{
|
||||
WIZCHIP_EXPORT(close)(sn);
|
||||
return SOCKFATAL_PACKLEN;
|
||||
|
@ -582,7 +582,7 @@ int8_t WIZCHIP_EXPORT(ctlsocket)(uint8_t sn, ctlsock_type cstype, void* arg)
|
|||
else if(tmp == SOCK_IO_BLOCK) sock_io_mode &= ~(1<<sn);
|
||||
else return SOCKERR_ARG;
|
||||
break;
|
||||
case CS_GET_IOMODE:
|
||||
case CS_GET_IOMODE:
|
||||
//M20140501 : implict type casting -> explict type casting
|
||||
//*((uint8_t*)arg) = (sock_io_mode >> sn) & 0x0001;
|
||||
*((uint8_t*)arg) = (uint8_t)((sock_io_mode >> sn) & 0x0001);
|
||||
|
@ -591,7 +591,7 @@ int8_t WIZCHIP_EXPORT(ctlsocket)(uint8_t sn, ctlsock_type cstype, void* arg)
|
|||
case CS_GET_MAXTXBUF:
|
||||
*((uint16_t*)arg) = getSn_TxMAX(sn);
|
||||
break;
|
||||
case CS_GET_MAXRXBUF:
|
||||
case CS_GET_MAXRXBUF:
|
||||
*((uint16_t*)arg) = getSn_RxMAX(sn);
|
||||
break;
|
||||
case CS_CLR_INTERRUPT:
|
||||
|
@ -601,11 +601,11 @@ int8_t WIZCHIP_EXPORT(ctlsocket)(uint8_t sn, ctlsock_type cstype, void* arg)
|
|||
case CS_GET_INTERRUPT:
|
||||
*((uint8_t*)arg) = getSn_IR(sn);
|
||||
break;
|
||||
case CS_SET_INTMASK:
|
||||
case CS_SET_INTMASK:
|
||||
if( (*(uint8_t*)arg) > SIK_ALL) return SOCKERR_ARG;
|
||||
setSn_IMR(sn,*(uint8_t*)arg);
|
||||
break;
|
||||
case CS_GET_INTMASK:
|
||||
case CS_GET_INTMASK:
|
||||
*((uint8_t*)arg) = getSn_IMR(sn);
|
||||
default:
|
||||
return SOCKERR_ARG;
|
||||
|
@ -658,11 +658,11 @@ int8_t WIZCHIP_EXPORT(setsockopt)(uint8_t sn, sockopt_type sotype, void* arg)
|
|||
CHECK_SOCKMODE(Sn_MR_TCP);
|
||||
setSn_KPALVTR(sn,*(uint8_t*)arg);
|
||||
break;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
default:
|
||||
return SOCKERR_ARG;
|
||||
}
|
||||
}
|
||||
return SOCK_OK;
|
||||
}
|
||||
|
||||
|
@ -680,20 +680,20 @@ int8_t WIZCHIP_EXPORT(getsockopt)(uint8_t sn, sockopt_type sotype, void* arg)
|
|||
case SO_TOS:
|
||||
*(uint8_t*) arg = getSn_TOS(sn);
|
||||
break;
|
||||
case SO_MSS:
|
||||
case SO_MSS:
|
||||
*(uint8_t*) arg = getSn_MSSR(sn);
|
||||
case SO_DESTIP:
|
||||
getSn_DIPR(sn, (uint8_t*)arg);
|
||||
break;
|
||||
case SO_DESTPORT:
|
||||
case SO_DESTPORT:
|
||||
*(uint16_t*) arg = getSn_DPORT(sn);
|
||||
break;
|
||||
#if _WIZCHIP_ > 5200
|
||||
#if _WIZCHIP_ > 5200
|
||||
case SO_KEEPALIVEAUTO:
|
||||
CHECK_SOCKMODE(Sn_MR_TCP);
|
||||
*(uint16_t*) arg = getSn_KPALVTR(sn);
|
||||
break;
|
||||
#endif
|
||||
#endif
|
||||
case SO_SENDBUF:
|
||||
*(uint16_t*) arg = getSn_TX_FSR(sn);
|
||||
case SO_RECVBUF:
|
||||
|
|
|
@ -2,43 +2,43 @@
|
|||
//
|
||||
//! \file socket.h
|
||||
//! \brief SOCKET APIs Header file.
|
||||
//! \details SOCKET APIs like as berkeley socket api.
|
||||
//! \details SOCKET APIs like as berkeley socket api.
|
||||
//! \version 1.0.2
|
||||
//! \date 2013/10/21
|
||||
//! \par Revision history
|
||||
//! <2014/05/01> V1.0.2. Refer to M20140501
|
||||
//! 1. Modify the comment : SO_REMAINED -> PACK_REMAINED
|
||||
//! 2. Add the comment as zero byte udp data reception in getsockopt().
|
||||
//! 2. Add the comment as zero byte udp data reception in getsockopt().
|
||||
//! <2013/10/21> 1st Release
|
||||
//! \author MidnightCow
|
||||
//! \copyright
|
||||
//!
|
||||
//! Copyright (c) 2013, WIZnet Co., LTD.
|
||||
//! All rights reserved.
|
||||
//!
|
||||
//! Redistribution and use in source and binary forms, with or without
|
||||
//! modification, are permitted provided that the following conditions
|
||||
//! are met:
|
||||
//!
|
||||
//! * Redistributions of source code must retain the above copyright
|
||||
//! notice, this list of conditions and the following disclaimer.
|
||||
//!
|
||||
//! Redistribution and use in source and binary forms, with or without
|
||||
//! modification, are permitted provided that the following conditions
|
||||
//! are met:
|
||||
//!
|
||||
//! * Redistributions of source code must retain the above copyright
|
||||
//! notice, this list of conditions and the following disclaimer.
|
||||
//! * Redistributions in binary form must reproduce the above copyright
|
||||
//! notice, this list of conditions and the following disclaimer in the
|
||||
//! documentation and/or other materials provided with the distribution.
|
||||
//! * Neither the name of the <ORGANIZATION> nor the names of its
|
||||
//! contributors may be used to endorse or promote products derived
|
||||
//! from this software without specific prior written permission.
|
||||
//!
|
||||
//! documentation and/or other materials provided with the distribution.
|
||||
//! * Neither the name of the <ORGANIZATION> nor the names of its
|
||||
//! contributors may be used to endorse or promote products derived
|
||||
//! from this software without specific prior written permission.
|
||||
//!
|
||||
//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
//! AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
//! AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
//! IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
//! ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
//! LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
//! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
//! ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
//! LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
//! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
//! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
//! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
//! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
//! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
//! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
//! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
//! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
//! THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
@ -92,7 +92,7 @@
|
|||
#define SOCK_BUSY 0 ///< Socket is busy on processing the operation. Valid only Non-block IO Mode.
|
||||
#define SOCK_FATAL -1000 ///< Result is fatal error about socket process.
|
||||
|
||||
#define SOCK_ERROR 0
|
||||
#define SOCK_ERROR 0
|
||||
#define SOCKERR_SOCKNUM (SOCK_ERROR - 1) ///< Invalid socket number
|
||||
#define SOCKERR_SOCKOPT (SOCK_ERROR - 2) ///< Invalid socket option
|
||||
#define SOCKERR_SOCKINIT (SOCK_ERROR - 3) ///< Socket is not initialized
|
||||
|
@ -113,7 +113,7 @@
|
|||
* SOCKET FLAG
|
||||
*/
|
||||
#define SF_ETHER_OWN (Sn_MR_MFEN) ///< In \ref Sn_MR_MACRAW, Receive only the packet as broadcast, multicast and own packet
|
||||
#define SF_IGMP_VER2 (Sn_MR_MC) ///< In \ref Sn_MR_UDP with \ref SF_MULTI_ENABLE, Select IGMP version 2.
|
||||
#define SF_IGMP_VER2 (Sn_MR_MC) ///< In \ref Sn_MR_UDP with \ref SF_MULTI_ENABLE, Select IGMP version 2.
|
||||
#define SF_TCP_NODELAY (Sn_MR_ND) ///< In \ref Sn_MR_TCP, Use to nodelayed ack.
|
||||
#define SF_MULTI_ENABLE (Sn_MR_MULTI) ///< In \ref Sn_MR_UDP, Enable multicast mode.
|
||||
|
||||
|
@ -184,7 +184,7 @@ int8_t WIZCHIP_EXPORT(listen)(uint8_t sn);
|
|||
* @ingroup WIZnet_socket_APIs
|
||||
* @brief Try to connect a server.
|
||||
* @details It requests connection to the server with destination IP address and port number passed as parameter.\n
|
||||
* @note It is valid only in TCP client mode.
|
||||
* @note It is valid only in TCP client mode.
|
||||
* In block io mode, it does not return until connection is completed.
|
||||
* In Non-block io mode, it return @ref SOCK_BUSY immediately.
|
||||
*
|
||||
|
@ -286,7 +286,7 @@ int32_t WIZCHIP_EXPORT(recv)(uint8_t sn, uint8_t * buf, uint16_t len);
|
|||
* @ref SOCKERR_PORTZERO - Server port zero\n
|
||||
* @ref SOCKERR_SOCKCLOSED - Socket unexpectedly closed \n
|
||||
* @ref SOCKERR_TIMEOUT - Timeout occurred \n
|
||||
* @ref SOCK_BUSY - Socket is busy.
|
||||
* @ref SOCK_BUSY - Socket is busy.
|
||||
*/
|
||||
int32_t WIZCHIP_EXPORT(sendto)(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port);
|
||||
|
||||
|
@ -294,7 +294,7 @@ int32_t WIZCHIP_EXPORT(sendto)(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t
|
|||
* @ingroup WIZnet_socket_APIs
|
||||
* @brief Receive datagram of UDP or MACRAW
|
||||
* @details This function is an application I/F function which is used to receive the data in other then TCP mode. \n
|
||||
* This function is used to receive UDP and MAC_RAW mode, and handle the header as well.
|
||||
* This function is used to receive UDP and MAC_RAW mode, and handle the header as well.
|
||||
* This function can divide to received the packet data.
|
||||
* On the MACRAW SOCKET, the addr and port parameters are ignored.
|
||||
* @note In block io mode, it doesn't return until data reception is completed - data is filled as <I>len</I> in socket buffer
|
||||
|
@ -302,7 +302,7 @@ int32_t WIZCHIP_EXPORT(sendto)(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t
|
|||
*
|
||||
* @param sn Socket number. It should be <b>0 ~ @ref \_WIZCHIP_SOCK_NUM_</b>.
|
||||
* @param buf Pointer buffer to read incoming data.
|
||||
* @param len The max data length of data in buf.
|
||||
* @param len The max data length of data in buf.
|
||||
* When the received packet size <= len, receives data as packet sized.
|
||||
* When others, receives data as len.
|
||||
* @param addr Pointer variable of destination IP address. It should be allocated 4 bytes.
|
||||
|
@ -366,7 +366,7 @@ typedef enum
|
|||
/**
|
||||
* @ingroup DATA_TYPE
|
||||
* @brief The type of socket option in @ref setsockopt() or @ref getsockopt()
|
||||
*/
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
SO_FLAG, ///< Valid only in getsockopt(), For set flag of socket refer to <I>flag</I> in @ref socket().
|
||||
|
@ -375,11 +375,11 @@ typedef enum
|
|||
SO_MSS, ///< Set/Get MSS. @ref Sn_MSSR ( @ref setSn_MSSR(), @ref getSn_MSSR() )
|
||||
SO_DESTIP, ///< Set/Get the destination IP address. @ref Sn_DIPR ( @ref setSn_DIPR(), @ref getSn_DIPR() )
|
||||
SO_DESTPORT, ///< Set/Get the destination Port number. @ref Sn_DPORT ( @ref setSn_DPORT(), @ref getSn_DPORT() )
|
||||
#if _WIZCHIP_ != 5100
|
||||
#if _WIZCHIP_ != 5100
|
||||
SO_KEEPALIVESEND, ///< Valid only in setsockopt. Manually send keep-alive packet in TCP mode
|
||||
#if _WIZCHIP_ > 5200
|
||||
#if _WIZCHIP_ > 5200
|
||||
SO_KEEPALIVEAUTO, ///< Set/Get keep-alive auto transmission timer in TCP mode
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
SO_SENDBUF, ///< Valid only in getsockopt. Get the free data size of Socekt TX buffer. @ref Sn_TX_FSR, @ref getSn_TX_FSR()
|
||||
SO_RECVBUF, ///< Valid only in getsockopt. Get the received data size in socket RX buffer. @ref Sn_RX_RSR, @ref getSn_RX_RSR()
|
||||
|
@ -400,34 +400,34 @@ typedef enum
|
|||
* <tr> <td> @b cstype </td> <td> @b data type</td><td>@b value</td></tr>
|
||||
* <tr> <td> @ref CS_SET_IOMODE \n @ref CS_GET_IOMODE </td> <td> uint8_t </td><td>@ref SOCK_IO_BLOCK @ref SOCK_IO_NONBLOCK</td></tr>
|
||||
* <tr> <td> @ref CS_GET_MAXTXBUF \n @ref CS_GET_MAXRXBUF </td> <td> uint16_t </td><td> 0 ~ 16K </td></tr>
|
||||
* <tr> <td> @ref CS_CLR_INTERRUPT \n @ref CS_GET_INTERRUPT \n @ref CS_SET_INTMASK \n @ref CS_GET_INTMASK </td> <td> @ref sockint_kind </td><td> @ref SIK_CONNECTED, etc. </td></tr>
|
||||
* <tr> <td> @ref CS_CLR_INTERRUPT \n @ref CS_GET_INTERRUPT \n @ref CS_SET_INTMASK \n @ref CS_GET_INTMASK </td> <td> @ref sockint_kind </td><td> @ref SIK_CONNECTED, etc. </td></tr>
|
||||
* </table>
|
||||
* @return @b Success @ref SOCK_OK \n
|
||||
* @b fail @ref SOCKERR_ARG - Invalid argument\n
|
||||
*/
|
||||
int8_t WIZCHIP_EXPORT(ctlsocket)(uint8_t sn, ctlsock_type cstype, void* arg);
|
||||
|
||||
/**
|
||||
/**
|
||||
* @ingroup WIZnet_socket_APIs
|
||||
* @brief set socket options
|
||||
* @details Set socket option like as TTL, MSS, TOS, and so on. Refer to @ref sockopt_type.
|
||||
*
|
||||
*
|
||||
* @param sn socket number
|
||||
* @param sotype socket option type. refer to @ref sockopt_type
|
||||
* @param arg Data type and value is determined according to <I>sotype</I>. \n
|
||||
* <table>
|
||||
* <tr> <td> @b sotype </td> <td> @b data type</td><td>@b value</td></tr>
|
||||
* <tr> <td> @b sotype </td> <td> @b data type</td><td>@b value</td></tr>
|
||||
* <tr> <td> @ref SO_TTL </td> <td> uint8_t </td><td> 0 ~ 255 </td> </tr>
|
||||
* <tr> <td> @ref SO_TOS </td> <td> uint8_t </td><td> 0 ~ 255 </td> </tr>
|
||||
* <tr> <td> @ref SO_MSS </td> <td> uint16_t </td><td> 0 ~ 65535 </td> </tr>
|
||||
* <tr> <td> @ref SO_DESTIP </td> <td> uint8_t[4] </td><td> </td></tr>
|
||||
* <tr> <td> @ref SO_DESTPORT </td> <td> uint16_t </td><td> 0 ~ 65535 </td></tr>
|
||||
* <tr> <td> @ref SO_KEEPALIVESEND </td> <td> null </td><td> null </td></tr>
|
||||
* <tr> <td> @ref SO_KEEPALIVEAUTO </td> <td> uint8_t </td><td> 0 ~ 255 </td></tr>
|
||||
* <tr> <td> @ref SO_DESTIP </td> <td> uint8_t[4] </td><td> </td></tr>
|
||||
* <tr> <td> @ref SO_DESTPORT </td> <td> uint16_t </td><td> 0 ~ 65535 </td></tr>
|
||||
* <tr> <td> @ref SO_KEEPALIVESEND </td> <td> null </td><td> null </td></tr>
|
||||
* <tr> <td> @ref SO_KEEPALIVEAUTO </td> <td> uint8_t </td><td> 0 ~ 255 </td></tr>
|
||||
* </table>
|
||||
* @return
|
||||
* @return
|
||||
* - @b Success : @ref SOCK_OK \n
|
||||
* - @b Fail
|
||||
* - @b Fail
|
||||
* - @ref SOCKERR_SOCKNUM - Invalid Socket number \n
|
||||
* - @ref SOCKERR_SOCKMODE - Invalid socket mode \n
|
||||
* - @ref SOCKERR_SOCKOPT - Invalid socket option or its value \n
|
||||
|
@ -435,7 +435,7 @@ int8_t WIZCHIP_EXPORT(ctlsocket)(uint8_t sn, ctlsock_type cstype, void* arg);
|
|||
*/
|
||||
int8_t WIZCHIP_EXPORT(setsockopt)(uint8_t sn, sockopt_type sotype, void* arg);
|
||||
|
||||
/**
|
||||
/**
|
||||
* @ingroup WIZnet_socket_APIs
|
||||
* @brief get socket options
|
||||
* @details Get socket option like as FLAG, TTL, MSS, and so on. Refer to @ref sockopt_type
|
||||
|
@ -447,24 +447,24 @@ int8_t WIZCHIP_EXPORT(setsockopt)(uint8_t sn, sockopt_type sotype, void* arg);
|
|||
* <tr> <td> @ref SO_FLAG </td> <td> uint8_t </td><td> @ref SF_ETHER_OWN, etc... </td> </tr>
|
||||
* <tr> <td> @ref SO_TOS </td> <td> uint8_t </td><td> 0 ~ 255 </td> </tr>
|
||||
* <tr> <td> @ref SO_MSS </td> <td> uint16_t </td><td> 0 ~ 65535 </td> </tr>
|
||||
* <tr> <td> @ref SO_DESTIP </td> <td> uint8_t[4] </td><td> </td></tr>
|
||||
* <tr> <td> @ref SO_DESTPORT </td> <td> uint16_t </td><td> </td></tr>
|
||||
* <tr> <td> @ref SO_KEEPALIVEAUTO </td> <td> uint8_t </td><td> 0 ~ 255 </td></tr>
|
||||
* <tr> <td> @ref SO_SENDBUF </td> <td> uint16_t </td><td> 0 ~ 65535 </td></tr>
|
||||
* <tr> <td> @ref SO_RECVBUF </td> <td> uint16_t </td><td> 0 ~ 65535 </td></tr>
|
||||
* <tr> <td> @ref SO_STATUS </td> <td> uint8_t </td><td> @ref SOCK_ESTABLISHED, etc.. </td></tr>
|
||||
* <tr> <td> @ref SO_DESTIP </td> <td> uint8_t[4] </td><td> </td></tr>
|
||||
* <tr> <td> @ref SO_DESTPORT </td> <td> uint16_t </td><td> </td></tr>
|
||||
* <tr> <td> @ref SO_KEEPALIVEAUTO </td> <td> uint8_t </td><td> 0 ~ 255 </td></tr>
|
||||
* <tr> <td> @ref SO_SENDBUF </td> <td> uint16_t </td><td> 0 ~ 65535 </td></tr>
|
||||
* <tr> <td> @ref SO_RECVBUF </td> <td> uint16_t </td><td> 0 ~ 65535 </td></tr>
|
||||
* <tr> <td> @ref SO_STATUS </td> <td> uint8_t </td><td> @ref SOCK_ESTABLISHED, etc.. </td></tr>
|
||||
* <tr> <td> @ref SO_REMAINSIZE </td> <td> uint16_t </td><td> 0~ 65535 </td></tr>
|
||||
* <tr> <td> @ref SO_PACKINFO </td> <td> uint8_t </td><td> @ref PACK_FIRST, etc... </td></tr>
|
||||
* </table>
|
||||
* @return
|
||||
* @return
|
||||
* - @b Success : @ref SOCK_OK \n
|
||||
* - @b Fail
|
||||
* - @b Fail
|
||||
* - @ref SOCKERR_SOCKNUM - Invalid Socket number \n
|
||||
* - @ref SOCKERR_SOCKOPT - Invalid socket option or its value \n
|
||||
* - @ref SOCKERR_SOCKMODE - Invalid socket mode \n
|
||||
* @note
|
||||
* The option as PACK_REMAINED and SO_PACKINFO is valid only in NON-TCP mode and after call @ref recvfrom(). \n
|
||||
* When SO_PACKINFO value is PACK_FIRST and the return value of recvfrom() is zero,
|
||||
* When SO_PACKINFO value is PACK_FIRST and the return value of recvfrom() is zero,
|
||||
* This means the zero byte UDP data(UDP Header only) received.
|
||||
*/
|
||||
int8_t WIZCHIP_EXPORT(getsockopt)(uint8_t sn, sockopt_type sotype, void* arg);
|
||||
|
|
|
@ -22,30 +22,30 @@
|
|||
//!
|
||||
//! Copyright (c) 2013, WIZnet Co., LTD.
|
||||
//! All rights reserved.
|
||||
//!
|
||||
//! Redistribution and use in source and binary forms, with or without
|
||||
//! modification, are permitted provided that the following conditions
|
||||
//! are met:
|
||||
//!
|
||||
//! * Redistributions of source code must retain the above copyright
|
||||
//! notice, this list of conditions and the following disclaimer.
|
||||
//!
|
||||
//! Redistribution and use in source and binary forms, with or without
|
||||
//! modification, are permitted provided that the following conditions
|
||||
//! are met:
|
||||
//!
|
||||
//! * Redistributions of source code must retain the above copyright
|
||||
//! notice, this list of conditions and the following disclaimer.
|
||||
//! * Redistributions in binary form must reproduce the above copyright
|
||||
//! notice, this list of conditions and the following disclaimer in the
|
||||
//! documentation and/or other materials provided with the distribution.
|
||||
//! * Neither the name of the <ORGANIZATION> nor the names of its
|
||||
//! contributors may be used to endorse or promote products derived
|
||||
//! from this software without specific prior written permission.
|
||||
//!
|
||||
//! documentation and/or other materials provided with the distribution.
|
||||
//! * Neither the name of the <ORGANIZATION> nor the names of its
|
||||
//! contributors may be used to endorse or promote products derived
|
||||
//! from this software without specific prior written permission.
|
||||
//!
|
||||
//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
//! AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
//! AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
//! IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
//! ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
//! LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
//! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
//! ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
//! LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
//! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
//! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
//! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
//! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
//! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
//! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
//! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
//! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
//! THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
|
|
@ -13,30 +13,30 @@
|
|||
//!
|
||||
//! Copyright (c) 2013, WIZnet Co., LTD.
|
||||
//! All rights reserved.
|
||||
//!
|
||||
//! Redistribution and use in source and binary forms, with or without
|
||||
//! modification, are permitted provided that the following conditions
|
||||
//! are met:
|
||||
//!
|
||||
//! * Redistributions of source code must retain the above copyright
|
||||
//! notice, this list of conditions and the following disclaimer.
|
||||
//!
|
||||
//! Redistribution and use in source and binary forms, with or without
|
||||
//! modification, are permitted provided that the following conditions
|
||||
//! are met:
|
||||
//!
|
||||
//! * Redistributions of source code must retain the above copyright
|
||||
//! notice, this list of conditions and the following disclaimer.
|
||||
//! * Redistributions in binary form must reproduce the above copyright
|
||||
//! notice, this list of conditions and the following disclaimer in the
|
||||
//! documentation and/or other materials provided with the distribution.
|
||||
//! * Neither the name of the <ORGANIZATION> nor the names of its
|
||||
//! contributors may be used to endorse or promote products derived
|
||||
//! from this software without specific prior written permission.
|
||||
//!
|
||||
//! documentation and/or other materials provided with the distribution.
|
||||
//! * Neither the name of the <ORGANIZATION> nor the names of its
|
||||
//! contributors may be used to endorse or promote products derived
|
||||
//! from this software without specific prior written permission.
|
||||
//!
|
||||
//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
//! AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
//! AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
//! IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
//! ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
//! LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
//! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
//! ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
//! LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
//! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
//! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
//! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
//! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
//! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
//! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
//! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
//! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
//! THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
@ -66,8 +66,8 @@
|
|||
* - @ref WIZCHIP_register : @ref Common_register_group and @ref Socket_register_group
|
||||
* - @ref WIZCHIP_IO_Functions : @ref Basic_IO_function, @ref Common_register_access_function and @ref Socket_register_access_function
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup WIZCHIP_register WIZCHIP register
|
||||
* @ingroup W5500
|
||||
|
@ -138,9 +138,9 @@
|
|||
* @sa UIPR, UPORTR : ICMP message.
|
||||
* @sa PHYCFGR, VERSIONR : etc.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup Socket_register_group Socket register
|
||||
* @ingroup WIZCHIP_register
|
||||
|
@ -153,9 +153,9 @@
|
|||
* @sa Sn_MSSR, Sn_TOS, Sn_TTL, Sn_KPALVTR, Sn_FRAG : Internet protocol.
|
||||
* @sa Sn_RXBUF_SIZE, Sn_TXBUF_SIZE, Sn_TX_FSR, Sn_TX_RD, Sn_TX_WR, Sn_RX_RSR, Sn_RX_RD, Sn_RX_WR : Data communication
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup Basic_IO_function Basic I/O function
|
||||
* @ingroup WIZCHIP_IO_Functions
|
||||
|
@ -173,7 +173,7 @@
|
|||
* @ingroup WIZCHIP_IO_Functions
|
||||
* @brief These are functions to access <b>socket registers</b>.
|
||||
*/
|
||||
|
||||
|
||||
//------------------------------- defgroup end --------------------------------------------
|
||||
//----------------------------- W5500 Common Registers IOMAP -----------------------------
|
||||
/**
|
||||
|
@ -276,7 +276,7 @@
|
|||
* @brief Socket Interrupt Mask Register(R/W)
|
||||
* @details Each bit of @ref SIMR corresponds to each bit of @ref SIR.
|
||||
* When a bit of @ref SIMR is and the corresponding bit of @ref SIR is Interrupt will be issued.
|
||||
* In other words, if a bit of @ref SIMR is an interrupt will be not issued even if the corresponding bit of @ref SIR is
|
||||
* In other words, if a bit of @ref SIMR is an interrupt will be not issued even if the corresponding bit of @ref SIR is
|
||||
*/
|
||||
//#define SIMR (_W5500_IO_BASE_ + (0x0018 << 8) + (WIZCHIP_CREG_BLOCK << 3))
|
||||
|
||||
|
@ -531,7 +531,7 @@
|
|||
*/
|
||||
#define Sn_TTL(N) WIZCHIP_SREG_ADDR(N, 0x0016)
|
||||
// Reserved (_W5500_IO_BASE_ + (0x0017 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
|
||||
// Reserved (_W5500_IO_BASE_ + (0x0018 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
|
||||
// Reserved (_W5500_IO_BASE_ + (0x0018 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
|
||||
// Reserved (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
|
||||
// Reserved (_W5500_IO_BASE_ + (0x001A << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
|
||||
// Reserved (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
|
||||
|
@ -633,8 +633,8 @@
|
|||
* @ingroup Socket_register_group
|
||||
* @brief socket interrupt mask register(R)
|
||||
* @details @ref Sn_IMR masks the interrupt of Socket n.
|
||||
* Each bit corresponds to each bit of @ref Sn_IR. When a Socket n Interrupt is occurred and the corresponding bit of @ref Sn_IMR is
|
||||
* the corresponding bit of @ref Sn_IR becomes When both the corresponding bit of @ref Sn_IMR and @ref Sn_IR are and the n-th bit of @ref IR is
|
||||
* Each bit corresponds to each bit of @ref Sn_IR. When a Socket n Interrupt is occurred and the corresponding bit of @ref Sn_IMR is
|
||||
* the corresponding bit of @ref Sn_IR becomes When both the corresponding bit of @ref Sn_IMR and @ref Sn_IR are and the n-th bit of @ref IR is
|
||||
* Host is interrupted by asserted INTn PIN to low.
|
||||
*/
|
||||
//#define Sn_IMR(N) (_W5500_IO_BASE_ + (0x002C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
|
||||
|
@ -694,7 +694,7 @@
|
|||
* @brief Enable PPPoE
|
||||
* @details 0 : DisablePPPoE mode\n
|
||||
* 1 : EnablePPPoE mode\n
|
||||
* If you use ADSL, this bit should be
|
||||
* If you use ADSL, this bit should be
|
||||
*/
|
||||
#define MR_PPPOE 0x08
|
||||
|
||||
|
@ -715,7 +715,7 @@
|
|||
|
||||
/**
|
||||
* @brief Get the destination unreachable message in UDP sending.
|
||||
* @details When receiving the ICMP (Destination port unreachable) packet, this bit is set as
|
||||
* @details When receiving the ICMP (Destination port unreachable) packet, this bit is set as
|
||||
* When this bit is Destination Information such as IP address and Port number may be checked with the corresponding @ref UIPR & @ref UPORTR.
|
||||
*/
|
||||
#define IR_UNREACH 0x40
|
||||
|
@ -743,7 +743,7 @@
|
|||
#define PHYCFGR_OPMDC_100F (3<<3)
|
||||
#define PHYCFGR_OPMDC_100H (2<<3)
|
||||
#define PHYCFGR_OPMDC_10F (1<<3)
|
||||
#define PHYCFGR_OPMDC_10H (0<<3)
|
||||
#define PHYCFGR_OPMDC_10H (0<<3)
|
||||
#define PHYCFGR_DPX_FULL (1<<2)
|
||||
#define PHYCFGR_DPX_HALF (0<<2)
|
||||
#define PHYCFGR_SPD_100 (1<<1)
|
||||
|
@ -818,7 +818,7 @@
|
|||
* @brief Unicast Block in UDP Multicasting
|
||||
* @details 0 : disable Unicast Blocking\n
|
||||
* 1 : enable Unicast Blocking\n
|
||||
* This bit blocks receiving the unicast packet during UDP mode(P[3:0] = 010 and MULTI =
|
||||
* This bit blocks receiving the unicast packet during UDP mode(P[3:0] = 010 and MULTI =
|
||||
*/
|
||||
//#define Sn_MR_UCASTB 0x10
|
||||
|
||||
|
@ -866,7 +866,7 @@
|
|||
* @brief Multicast Blocking in @ref Sn_MR_MACRAW mode
|
||||
* @details 0 : using IGMP version 2\n
|
||||
* 1 : using IGMP version 1\n
|
||||
* This bit is applied only during UDP mode(P[3:0] = 010 and MULTI =
|
||||
* This bit is applied only during UDP mode(P[3:0] = 010 and MULTI =
|
||||
* It configures the version for IGMP messages (Join/Leave/Report).
|
||||
*/
|
||||
#define Sn_MR_MMB Sn_MR_ND
|
||||
|
@ -921,7 +921,7 @@
|
|||
* In this mode, Socket n operates as a <EFBFBD>TCP serverand waits for connection-request (SYN packet) from any <EFBFBD>TCP client
|
||||
* The @ref Sn_SR changes the state from SOCK_INIT to SOCKET_LISTEN.
|
||||
* When a <EFBFBD>TCP clientconnection request is successfully established,
|
||||
* the @ref Sn_SR changes from SOCK_LISTEN to SOCK_ESTABLISHED and the Sn_IR(0) becomes
|
||||
* the @ref Sn_SR changes from SOCK_LISTEN to SOCK_ESTABLISHED and the Sn_IR(0) becomes
|
||||
* But when a <EFBFBD>TCP clientconnection request is failed, Sn_IR(3) becomes and the status of @ref Sn_SR changes to SOCK_CLOSED.
|
||||
*/
|
||||
#define Sn_CR_LISTEN 0x02
|
||||
|
@ -1132,7 +1132,7 @@
|
|||
//#define SOCK_PPPOE 0x5F
|
||||
|
||||
/* IP PROTOCOL */
|
||||
#define IPPROTO_IP 0 //< Dummy for IP
|
||||
#define IPPROTO_IP 0 //< Dummy for IP
|
||||
#define IPPROTO_ICMP 1 //< Control message protocol
|
||||
#define IPPROTO_IGMP 2 //< Internet group management protocol
|
||||
#define IPPROTO_GGP 3 //< Gateway^2 (deprecated)
|
||||
|
@ -2027,7 +2027,7 @@ uint16_t getSn_RX_RSR(uint8_t sn);
|
|||
/////////////////////////////////////
|
||||
// Sn_TXBUF & Sn_RXBUF IO function //
|
||||
/////////////////////////////////////
|
||||
/**
|
||||
/**
|
||||
* @brief Gets the max buffer size of socket sn passed as parameter.
|
||||
* @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>.
|
||||
* @return uint16_t. Value of Socket n RX max buffer size.
|
||||
|
@ -2035,7 +2035,7 @@ uint16_t getSn_RX_RSR(uint8_t sn);
|
|||
#define getSn_RxMAX(sn) \
|
||||
(getSn_RXBUF_SIZE(sn) << 10)
|
||||
|
||||
/**
|
||||
/**
|
||||
* @brief Gets the max buffer size of socket sn passed as parameters.
|
||||
* @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>.
|
||||
* @return uint16_t. Value of Socket n TX max buffer size.
|
||||
|
|
|
@ -20,30 +20,30 @@
|
|||
//!
|
||||
//! Copyright (c) 2013, WIZnet Co., LTD.
|
||||
//! All rights reserved.
|
||||
//!
|
||||
//! Redistribution and use in source and binary forms, with or without
|
||||
//! modification, are permitted provided that the following conditions
|
||||
//! are met:
|
||||
//!
|
||||
//! * Redistributions of source code must retain the above copyright
|
||||
//! notice, this list of conditions and the following disclaimer.
|
||||
//!
|
||||
//! Redistribution and use in source and binary forms, with or without
|
||||
//! modification, are permitted provided that the following conditions
|
||||
//! are met:
|
||||
//!
|
||||
//! * Redistributions of source code must retain the above copyright
|
||||
//! notice, this list of conditions and the following disclaimer.
|
||||
//! * Redistributions in binary form must reproduce the above copyright
|
||||
//! notice, this list of conditions and the following disclaimer in the
|
||||
//! documentation and/or other materials provided with the distribution.
|
||||
//! * Neither the name of the <ORGANIZATION> nor the names of its
|
||||
//! contributors may be used to endorse or promote products derived
|
||||
//! from this software without specific prior written permission.
|
||||
//!
|
||||
//! documentation and/or other materials provided with the distribution.
|
||||
//! * Neither the name of the <ORGANIZATION> nor the names of its
|
||||
//! contributors may be used to endorse or promote products derived
|
||||
//! from this software without specific prior written permission.
|
||||
//!
|
||||
//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
//! AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
//! AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
//! IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
//! ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
//! LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
//! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
//! ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
//! LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
//! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
//! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
//! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
//! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
//! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
//! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
//! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
//! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
//! THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
@ -114,7 +114,7 @@ void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb )
|
|||
WIZCHIP.CS._deselect();
|
||||
WIZCHIP_CRITICAL_EXIT();
|
||||
}
|
||||
|
||||
|
||||
void WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len)
|
||||
{
|
||||
uint8_t spi_data[3];
|
||||
|
@ -213,7 +213,7 @@ void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len)
|
|||
addrsel = ((uint32_t)ptr << 8) + (WIZCHIP_TXBUF_BLOCK(sn) << 3);
|
||||
//
|
||||
WIZCHIP_WRITE_BUF(addrsel,wizdata, len);
|
||||
|
||||
|
||||
ptr += len;
|
||||
setSn_TX_WR(sn,ptr);
|
||||
}
|
||||
|
@ -222,7 +222,7 @@ void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len)
|
|||
{
|
||||
uint16_t ptr = 0;
|
||||
uint32_t addrsel = 0;
|
||||
|
||||
|
||||
if(len == 0) return;
|
||||
ptr = getSn_RX_RD(sn);
|
||||
//M20140501 : implict type casting -> explict type casting
|
||||
|
@ -231,7 +231,7 @@ void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len)
|
|||
//
|
||||
WIZCHIP_READ_BUF(addrsel, wizdata, len);
|
||||
ptr += len;
|
||||
|
||||
|
||||
setSn_RX_RD(sn,ptr);
|
||||
}
|
||||
|
||||
|
@ -244,4 +244,3 @@ void wiz_recv_ignore(uint8_t sn, uint16_t len)
|
|||
ptr += len;
|
||||
setSn_RX_RD(sn,ptr);
|
||||
}
|
||||
|
||||
|
|
|
@ -11,30 +11,30 @@
|
|||
//!
|
||||
//! Copyright (c) 2013, WIZnet Co., LTD.
|
||||
//! All rights reserved.
|
||||
//!
|
||||
//! Redistribution and use in source and binary forms, with or without
|
||||
//! modification, are permitted provided that the following conditions
|
||||
//! are met:
|
||||
//!
|
||||
//! * Redistributions of source code must retain the above copyright
|
||||
//! notice, this list of conditions and the following disclaimer.
|
||||
//!
|
||||
//! Redistribution and use in source and binary forms, with or without
|
||||
//! modification, are permitted provided that the following conditions
|
||||
//! are met:
|
||||
//!
|
||||
//! * Redistributions of source code must retain the above copyright
|
||||
//! notice, this list of conditions and the following disclaimer.
|
||||
//! * Redistributions in binary form must reproduce the above copyright
|
||||
//! notice, this list of conditions and the following disclaimer in the
|
||||
//! documentation and/or other materials provided with the distribution.
|
||||
//! * Neither the name of the <ORGANIZATION> nor the names of its
|
||||
//! contributors may be used to endorse or promote products derived
|
||||
//! from this software without specific prior written permission.
|
||||
//!
|
||||
//! documentation and/or other materials provided with the distribution.
|
||||
//! * Neither the name of the <ORGANIZATION> nor the names of its
|
||||
//! contributors may be used to endorse or promote products derived
|
||||
//! from this software without specific prior written permission.
|
||||
//!
|
||||
//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
//! AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
//! AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
//! IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
//! ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
//! LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
//! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
//! ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
//! LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
//! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
//! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
//! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
//! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
//! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
//! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
//! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
//! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
//! THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
@ -76,8 +76,8 @@
|
|||
* - @ref WIZCHIP_register : @ref Common_register_group and @ref Socket_register_group
|
||||
* - @ref WIZCHIP_IO_Functions : @ref Basic_IO_function, @ref Common_register_access_function and @ref Socket_register_access_function
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup WIZCHIP_register WIZCHIP register
|
||||
* @ingroup W5500
|
||||
|
@ -148,9 +148,9 @@
|
|||
* @sa UIPR, UPORTR : ICMP message.
|
||||
* @sa PHYCFGR, VERSIONR : etc.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup Socket_register_group Socket register
|
||||
* @ingroup WIZCHIP_register
|
||||
|
@ -163,9 +163,9 @@
|
|||
* @sa Sn_MSSR, Sn_TOS, Sn_TTL, Sn_KPALVTR, Sn_FRAG : Internet protocol.
|
||||
* @sa Sn_RXBUF_SIZE, Sn_TXBUF_SIZE, Sn_TX_FSR, Sn_TX_RD, Sn_TX_WR, Sn_RX_RSR, Sn_RX_RD, Sn_RX_WR : Data communication
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup Basic_IO_function Basic I/O function
|
||||
* @ingroup WIZCHIP_IO_Functions
|
||||
|
@ -183,7 +183,7 @@
|
|||
* @ingroup WIZCHIP_IO_Functions
|
||||
* @brief These are functions to access <b>socket registers</b>.
|
||||
*/
|
||||
|
||||
|
||||
//------------------------------- defgroup end --------------------------------------------
|
||||
//----------------------------- W5500 Common Registers IOMAP -----------------------------
|
||||
/**
|
||||
|
@ -286,7 +286,7 @@
|
|||
* @brief Socket Interrupt Mask Register(R/W)
|
||||
* @details Each bit of @ref SIMR corresponds to each bit of @ref SIR.
|
||||
* When a bit of @ref SIMR is and the corresponding bit of @ref SIR is Interrupt will be issued.
|
||||
* In other words, if a bit of @ref SIMR is an interrupt will be not issued even if the corresponding bit of @ref SIR is
|
||||
* In other words, if a bit of @ref SIMR is an interrupt will be not issued even if the corresponding bit of @ref SIR is
|
||||
*/
|
||||
#define SIMR (_W5500_IO_BASE_ + (0x0018 << 8) + (WIZCHIP_CREG_BLOCK << 3))
|
||||
|
||||
|
@ -540,7 +540,7 @@
|
|||
*/
|
||||
#define Sn_TTL(N) (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
|
||||
// Reserved (_W5500_IO_BASE_ + (0x0017 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
|
||||
// Reserved (_W5500_IO_BASE_ + (0x0018 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
|
||||
// Reserved (_W5500_IO_BASE_ + (0x0018 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
|
||||
// Reserved (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
|
||||
// Reserved (_W5500_IO_BASE_ + (0x001A << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
|
||||
// Reserved (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
|
||||
|
@ -642,8 +642,8 @@
|
|||
* @ingroup Socket_register_group
|
||||
* @brief socket interrupt mask register(R)
|
||||
* @details @ref Sn_IMR masks the interrupt of Socket n.
|
||||
* Each bit corresponds to each bit of @ref Sn_IR. When a Socket n Interrupt is occurred and the corresponding bit of @ref Sn_IMR is
|
||||
* the corresponding bit of @ref Sn_IR becomes When both the corresponding bit of @ref Sn_IMR and @ref Sn_IR are and the n-th bit of @ref IR is
|
||||
* Each bit corresponds to each bit of @ref Sn_IR. When a Socket n Interrupt is occurred and the corresponding bit of @ref Sn_IMR is
|
||||
* the corresponding bit of @ref Sn_IR becomes When both the corresponding bit of @ref Sn_IMR and @ref Sn_IR are and the n-th bit of @ref IR is
|
||||
* Host is interrupted by asserted INTn PIN to low.
|
||||
*/
|
||||
#define Sn_IMR(N) (_W5500_IO_BASE_ + (0x002C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
|
||||
|
@ -703,7 +703,7 @@
|
|||
* @brief Enable PPPoE
|
||||
* @details 0 : DisablePPPoE mode\n
|
||||
* 1 : EnablePPPoE mode\n
|
||||
* If you use ADSL, this bit should be
|
||||
* If you use ADSL, this bit should be
|
||||
*/
|
||||
#define MR_PPPOE 0x08
|
||||
|
||||
|
@ -724,7 +724,7 @@
|
|||
|
||||
/**
|
||||
* @brief Get the destination unreachable message in UDP sending.
|
||||
* @details When receiving the ICMP (Destination port unreachable) packet, this bit is set as
|
||||
* @details When receiving the ICMP (Destination port unreachable) packet, this bit is set as
|
||||
* When this bit is Destination Information such as IP address and Port number may be checked with the corresponding @ref UIPR & @ref UPORTR.
|
||||
*/
|
||||
#define IR_UNREACH 0x40
|
||||
|
@ -752,7 +752,7 @@
|
|||
#define PHYCFGR_OPMDC_100F (3<<3)
|
||||
#define PHYCFGR_OPMDC_100H (2<<3)
|
||||
#define PHYCFGR_OPMDC_10F (1<<3)
|
||||
#define PHYCFGR_OPMDC_10H (0<<3)
|
||||
#define PHYCFGR_OPMDC_10H (0<<3)
|
||||
#define PHYCFGR_DPX_FULL (1<<2)
|
||||
#define PHYCFGR_DPX_HALF (0<<2)
|
||||
#define PHYCFGR_SPD_100 (1<<1)
|
||||
|
@ -823,7 +823,7 @@
|
|||
* @brief Unicast Block in UDP Multicasting
|
||||
* @details 0 : disable Unicast Blocking\n
|
||||
* 1 : enable Unicast Blocking\n
|
||||
* This bit blocks receiving the unicast packet during UDP mode(P[3:0] = 010 and MULTI =
|
||||
* This bit blocks receiving the unicast packet during UDP mode(P[3:0] = 010 and MULTI =
|
||||
*/
|
||||
#define Sn_MR_UCASTB 0x10
|
||||
|
||||
|
@ -871,7 +871,7 @@
|
|||
* @brief Multicast Blocking in @ref Sn_MR_MACRAW mode
|
||||
* @details 0 : using IGMP version 2\n
|
||||
* 1 : using IGMP version 1\n
|
||||
* This bit is applied only during UDP mode(P[3:0] = 010 and MULTI =
|
||||
* This bit is applied only during UDP mode(P[3:0] = 010 and MULTI =
|
||||
* It configures the version for IGMP messages (Join/Leave/Report).
|
||||
*/
|
||||
#define Sn_MR_MMB Sn_MR_ND
|
||||
|
@ -926,7 +926,7 @@
|
|||
* In this mode, Socket n operates as a <EFBFBD>TCP serverand waits for connection-request (SYN packet) from any <EFBFBD>TCP client
|
||||
* The @ref Sn_SR changes the state from SOCK_INIT to SOCKET_LISTEN.
|
||||
* When a <EFBFBD>TCP clientconnection request is successfully established,
|
||||
* the @ref Sn_SR changes from SOCK_LISTEN to SOCK_ESTABLISHED and the Sn_IR(0) becomes
|
||||
* the @ref Sn_SR changes from SOCK_LISTEN to SOCK_ESTABLISHED and the Sn_IR(0) becomes
|
||||
* But when a <EFBFBD>TCP clientconnection request is failed, Sn_IR(3) becomes and the status of @ref Sn_SR changes to SOCK_CLOSED.
|
||||
*/
|
||||
#define Sn_CR_LISTEN 0x02
|
||||
|
@ -1137,7 +1137,7 @@
|
|||
//#define SOCK_PPPOE 0x5F
|
||||
|
||||
/* IP PROTOCOL */
|
||||
#define IPPROTO_IP 0 //< Dummy for IP
|
||||
#define IPPROTO_IP 0 //< Dummy for IP
|
||||
#define IPPROTO_ICMP 1 //< Control message protocol
|
||||
#define IPPROTO_IGMP 2 //< Internet group management protocol
|
||||
#define IPPROTO_GGP 3 //< Gateway^2 (deprecated)
|
||||
|
@ -1994,7 +1994,7 @@ uint16_t getSn_RX_RSR(uint8_t sn);
|
|||
/////////////////////////////////////
|
||||
// Sn_TXBUF & Sn_RXBUF IO function //
|
||||
/////////////////////////////////////
|
||||
/**
|
||||
/**
|
||||
* @brief Gets the max buffer size of socket sn passed as parameter.
|
||||
* @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>.
|
||||
* @return uint16_t. Value of Socket n RX max buffer size.
|
||||
|
@ -2002,7 +2002,7 @@ uint16_t getSn_RX_RSR(uint8_t sn);
|
|||
#define getSn_RxMAX(sn) \
|
||||
(getSn_RXBUF_SIZE(sn) << 10)
|
||||
|
||||
/**
|
||||
/**
|
||||
* @brief Gets the max buffer size of socket sn passed as parameters.
|
||||
* @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>.
|
||||
* @return uint16_t. Value of Socket n TX max buffer size.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//****************************************************************************/
|
||||
//****************************************************************************/
|
||||
//!
|
||||
//! \file wizchip_conf.c
|
||||
//! \brief WIZCHIP Config Header File.
|
||||
|
@ -17,30 +17,30 @@
|
|||
//!
|
||||
//! Copyright (c) 2013, WIZnet Co., LTD.
|
||||
//! All rights reserved.
|
||||
//!
|
||||
//! Redistribution and use in source and binary forms, with or without
|
||||
//! modification, are permitted provided that the following conditions
|
||||
//! are met:
|
||||
//!
|
||||
//! * Redistributions of source code must retain the above copyright
|
||||
//! notice, this list of conditions and the following disclaimer.
|
||||
//!
|
||||
//! Redistribution and use in source and binary forms, with or without
|
||||
//! modification, are permitted provided that the following conditions
|
||||
//! are met:
|
||||
//!
|
||||
//! * Redistributions of source code must retain the above copyright
|
||||
//! notice, this list of conditions and the following disclaimer.
|
||||
//! * Redistributions in binary form must reproduce the above copyright
|
||||
//! notice, this list of conditions and the following disclaimer in the
|
||||
//! documentation and/or other materials provided with the distribution.
|
||||
//! * Neither the name of the <ORGANIZATION> nor the names of its
|
||||
//! contributors may be used to endorse or promote products derived
|
||||
//! from this software without specific prior written permission.
|
||||
//!
|
||||
//! documentation and/or other materials provided with the distribution.
|
||||
//! * Neither the name of the <ORGANIZATION> nor the names of its
|
||||
//! contributors may be used to endorse or promote products derived
|
||||
//! from this software without specific prior written permission.
|
||||
//!
|
||||
//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
//! AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
//! AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
//! IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
//! ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
//! LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
//! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
//! ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
//! LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
//! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
//! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
//! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
//! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
//! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
//! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
//! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
//! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
//! THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
//*****************************************************************************/
|
||||
|
@ -88,7 +88,7 @@ uint8_t wizchip_bus_readbyte(uint32_t AddrSel) { return * ((volatile uint8_t *)(
|
|||
* @note This function help not to access wrong address. If you do not describe this function or register any functions,
|
||||
* null function is called.
|
||||
*/
|
||||
|
||||
|
||||
//M20140501 : Explict pointer type casting
|
||||
//void wizchip_bus_writebyte(uint32_t AddrSel, uint8_t wb) { *((volatile uint8_t*) AddrSel) = wb; };
|
||||
void wizchip_bus_writebyte(uint32_t AddrSel, uint8_t wb) { *((volatile uint8_t*)((ptrdiff_t)AddrSel)) = wb; };
|
||||
|
@ -160,7 +160,7 @@ void reg_wizchip_cs_cbfunc(void(*cs_sel)(void), void(*cs_desel)(void))
|
|||
void reg_wizchip_bus_cbfunc(uint8_t(*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, uint8_t wb))
|
||||
{
|
||||
while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_BUS_));
|
||||
|
||||
|
||||
if(!bus_rb || !bus_wb)
|
||||
{
|
||||
WIZCHIP.IF.BUS._read_byte = wizchip_bus_readbyte;
|
||||
|
@ -176,7 +176,7 @@ void reg_wizchip_bus_cbfunc(uint8_t(*bus_rb)(uint32_t addr), void (*bus_wb)(uint
|
|||
void reg_wizchip_spi_cbfunc(void (*spi_rb)(uint8_t *, uint32_t), void (*spi_wb)(const uint8_t *, uint32_t))
|
||||
{
|
||||
while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_SPI_));
|
||||
|
||||
|
||||
if(!spi_rb || !spi_wb)
|
||||
{
|
||||
WIZCHIP.IF.SPI._read_bytes = wizchip_spi_readbytes;
|
||||
|
@ -199,7 +199,7 @@ int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg)
|
|||
wizchip_sw_reset();
|
||||
break;
|
||||
case CW_INIT_WIZCHIP:
|
||||
if(arg != 0)
|
||||
if(arg != 0)
|
||||
{
|
||||
ptmp[0] = (uint8_t*)arg;
|
||||
ptmp[1] = ptmp[0] + _WIZCHIP_SOCK_NUM_;
|
||||
|
@ -213,7 +213,7 @@ int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg)
|
|||
break;
|
||||
case CW_SET_INTRMASK:
|
||||
wizchip_setinterruptmask(*((intr_kind*)arg));
|
||||
break;
|
||||
break;
|
||||
case CW_GET_INTRMASK:
|
||||
*((intr_kind*)arg) = wizchip_getinterruptmask();
|
||||
break;
|
||||
|
@ -267,7 +267,7 @@ int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg)
|
|||
|
||||
int8_t ctlnetwork(ctlnetwork_type cntype, void* arg)
|
||||
{
|
||||
|
||||
|
||||
switch(cntype)
|
||||
{
|
||||
case CN_SET_NETINFO:
|
||||
|
@ -346,7 +346,7 @@ void wizchip_clrinterrupt(intr_kind intr)
|
|||
#if _WIZCHIP_ == 5200
|
||||
ir |= (1 << 6);
|
||||
#endif
|
||||
|
||||
|
||||
#if _WIZCHIP_ < 5200
|
||||
sir &= 0x0F;
|
||||
#endif
|
||||
|
@ -357,7 +357,7 @@ void wizchip_clrinterrupt(intr_kind intr)
|
|||
#else
|
||||
setIR(ir);
|
||||
setSIR(sir);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
intr_kind wizchip_getinterrupt(void)
|
||||
|
@ -371,7 +371,7 @@ intr_kind wizchip_getinterrupt(void)
|
|||
#else
|
||||
ir = getIR();
|
||||
sir = getSIR();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if _WIZCHIP_ < 5500
|
||||
ir &= ~(1<<4); // IK_WOL
|
||||
|
@ -394,7 +394,7 @@ void wizchip_setinterruptmask(intr_kind intr)
|
|||
#if _WIZCHIP_ == 5200
|
||||
imr &= ~(1 << 6);
|
||||
#endif
|
||||
|
||||
|
||||
#if _WIZCHIP_ < 5200
|
||||
simr &= 0x0F;
|
||||
#endif
|
||||
|
@ -405,7 +405,7 @@ void wizchip_setinterruptmask(intr_kind intr)
|
|||
#else
|
||||
setIMR(imr);
|
||||
setSIMR(simr);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
intr_kind wizchip_getinterruptmask(void)
|
||||
|
@ -419,7 +419,7 @@ intr_kind wizchip_getinterruptmask(void)
|
|||
#else
|
||||
imr = getIMR();
|
||||
simr = getSIMR();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if _WIZCHIP_ < 5500
|
||||
imr &= ~(1<<4); // IK_WOL
|
||||
|
@ -459,12 +459,12 @@ int8_t wizphy_getphypmode(void)
|
|||
#if _WIZCHIP_ == 5200
|
||||
if(getPHYSTATUS() & PHYSTATUS_POWERDOWN)
|
||||
tmp = PHY_POWER_DOWN;
|
||||
else
|
||||
else
|
||||
tmp = PHY_POWER_NORM;
|
||||
#elif _WIZCHIP_ == 5500
|
||||
if(getPHYCFGR() & PHYCFGR_OPMDC_PDOWN)
|
||||
tmp = PHY_POWER_DOWN;
|
||||
else
|
||||
else
|
||||
tmp = PHY_POWER_NORM;
|
||||
#else
|
||||
tmp = -1;
|
||||
|
@ -479,7 +479,7 @@ void wizphy_reset(void)
|
|||
uint8_t tmp = getPHYCFGR();
|
||||
tmp &= PHYCFGR_RST;
|
||||
setPHYCFGR(tmp);
|
||||
tmp = getPHYCFGR();
|
||||
tmp = getPHYCFGR();
|
||||
tmp |= ~PHYCFGR_RST;
|
||||
setPHYCFGR(tmp);
|
||||
}
|
||||
|
@ -501,7 +501,7 @@ void wizphy_setphyconf(wiz_PhyConf* phyconf)
|
|||
tmp |= PHYCFGR_OPMDC_100F;
|
||||
else
|
||||
tmp |= PHYCFGR_OPMDC_10F;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(phyconf->speed == PHY_SPEED_100)
|
||||
|
@ -522,7 +522,7 @@ void wizphy_getphyconf(wiz_PhyConf* phyconf)
|
|||
switch(tmp & PHYCFGR_OPMDC_ALLA)
|
||||
{
|
||||
case PHYCFGR_OPMDC_ALLA:
|
||||
case PHYCFGR_OPMDC_100FA:
|
||||
case PHYCFGR_OPMDC_100FA:
|
||||
phyconf->mode = PHY_MODE_AUTONEGO;
|
||||
break;
|
||||
default:
|
||||
|
@ -565,7 +565,7 @@ int8_t wizphy_setphypmode(uint8_t pmode)
|
|||
uint8_t tmp = 0;
|
||||
tmp = getPHYCFGR();
|
||||
if((tmp & PHYCFGR_OPMD)== 0) return -1;
|
||||
tmp &= ~PHYCFGR_OPMDC_ALLA;
|
||||
tmp &= ~PHYCFGR_OPMDC_ALLA;
|
||||
if( pmode == PHY_POWER_DOWN)
|
||||
tmp |= PHYCFGR_OPMDC_PDOWN;
|
||||
else
|
||||
|
@ -633,11 +633,11 @@ uint8_t *wizchip_getsubn(void) {
|
|||
int8_t wizchip_setnetmode(netmode_type netmode)
|
||||
{
|
||||
uint8_t tmp = 0;
|
||||
#if _WIZCHIP_ != 5500
|
||||
#if _WIZCHIP_ != 5500
|
||||
if(netmode & ~(NM_WAKEONLAN | NM_PPPOE | NM_PINGBLOCK)) return -1;
|
||||
#else
|
||||
if(netmode & ~(NM_WAKEONLAN | NM_PPPOE | NM_PINGBLOCK | NM_FORCEARP)) return -1;
|
||||
#endif
|
||||
#endif
|
||||
tmp = getMR();
|
||||
tmp |= (uint8_t)netmode;
|
||||
setMR(tmp);
|
||||
|
|
|
@ -11,30 +11,30 @@
|
|||
//!
|
||||
//! Copyright (c) 2013, WIZnet Co., LTD.
|
||||
//! All rights reserved.
|
||||
//!
|
||||
//! Redistribution and use in source and binary forms, with or without
|
||||
//! modification, are permitted provided that the following conditions
|
||||
//! are met:
|
||||
//!
|
||||
//! * Redistributions of source code must retain the above copyright
|
||||
//! notice, this list of conditions and the following disclaimer.
|
||||
//!
|
||||
//! Redistribution and use in source and binary forms, with or without
|
||||
//! modification, are permitted provided that the following conditions
|
||||
//! are met:
|
||||
//!
|
||||
//! * Redistributions of source code must retain the above copyright
|
||||
//! notice, this list of conditions and the following disclaimer.
|
||||
//! * Redistributions in binary form must reproduce the above copyright
|
||||
//! notice, this list of conditions and the following disclaimer in the
|
||||
//! documentation and/or other materials provided with the distribution.
|
||||
//! * Neither the name of the <ORGANIZATION> nor the names of its
|
||||
//! contributors may be used to endorse or promote products derived
|
||||
//! from this software without specific prior written permission.
|
||||
//!
|
||||
//! documentation and/or other materials provided with the distribution.
|
||||
//! * Neither the name of the <ORGANIZATION> nor the names of its
|
||||
//! contributors may be used to endorse or promote products derived
|
||||
//! from this software without specific prior written permission.
|
||||
//!
|
||||
//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
//! AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
//! AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
//! IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
//! ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
//! LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
//! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
//! ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
//! LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
//! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
//! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
//! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
//! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
//! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
//! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
//! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
//! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
//! THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
@ -42,9 +42,9 @@
|
|||
/**
|
||||
* @defgroup extra_functions 2. WIZnet Extra Functions
|
||||
*
|
||||
* @brief These functions is optional function. It could be replaced at WIZCHIP I/O function because they were made by WIZCHIP I/O functions.
|
||||
* @brief These functions is optional function. It could be replaced at WIZCHIP I/O function because they were made by WIZCHIP I/O functions.
|
||||
* @details There are functions of configuring WIZCHIP, network, interrupt, phy, network information and timer. \n
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _WIZCHIP_CONF_H_
|
||||
|
@ -97,10 +97,10 @@
|
|||
#include "w5200/w5200.h"
|
||||
#elif (_WIZCHIP_ == 5500)
|
||||
#define _WIZCHIP_ID_ "W5500\0"
|
||||
|
||||
|
||||
/**
|
||||
* @brief Define interface mode. \n
|
||||
* @todo Should select interface mode as chip.
|
||||
* @todo Should select interface mode as chip.
|
||||
* - @ref \_WIZCHIP_IO_MODE_SPI_ \n
|
||||
* -@ref \_WIZCHIP_IO_MODE_SPI_VDM_ : Valid only in @ref \_WIZCHIP_ == 5500 \n
|
||||
* -@ref \_WIZCHIP_IO_MODE_SPI_FDM_ : Valid only in @ref \_WIZCHIP_ == 5500 \n
|
||||
|
@ -109,12 +109,12 @@
|
|||
* - @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ \n
|
||||
* - Others will be defined in future. \n\n
|
||||
* ex> <code> #define \_WIZCHIP_IO_MODE_ \_WIZCHIP_IO_MODE_SPI_VDM_ </code>
|
||||
*
|
||||
*
|
||||
*/
|
||||
//#define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_FDM_
|
||||
#define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_VDM_
|
||||
#include "w5500/w5500.h"
|
||||
#else
|
||||
#else
|
||||
#error "Unknown defined _WIZCHIP_. You should define one of 5100, 5200, and 5500 !!!"
|
||||
#endif
|
||||
|
||||
|
@ -128,19 +128,19 @@
|
|||
* @ref \_WIZCHIP_IO_MODE_BUS_DIR_, @ref \_WIZCHIP_IO_MODE_BUS_INDIR_). \n\n
|
||||
* ex> <code> #define \_WIZCHIP_IO_BASE_ 0x00008000 </code>
|
||||
*/
|
||||
#define _WIZCHIP_IO_BASE_ 0x00000000 //
|
||||
#define _WIZCHIP_IO_BASE_ 0x00000000 //
|
||||
|
||||
#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_
|
||||
#ifndef _WIZCHIP_IO_BASE_
|
||||
#error "You should be define _WIZCHIP_IO_BASE to fit your system memory map."
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if _WIZCHIP_ > 5100
|
||||
#define _WIZCHIP_SOCK_NUM_ 8 ///< The count of independant socket of @b WIZCHIP
|
||||
#else
|
||||
#define _WIZCHIP_SOCK_NUM_ 4 ///< The count of independant socket of @b WIZCHIP
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/********************************************************
|
||||
|
@ -159,9 +159,9 @@ typedef struct __WIZCHIP
|
|||
*/
|
||||
struct _CRIS
|
||||
{
|
||||
void (*_enter) (void); ///< crtical section enter
|
||||
void (*_exit) (void); ///< critial section exit
|
||||
}CRIS;
|
||||
void (*_enter) (void); ///< crtical section enter
|
||||
void (*_exit) (void); ///< critial section exit
|
||||
}CRIS;
|
||||
/**
|
||||
* The set of @ref\_WIZCHIP_ select control callback func.
|
||||
*/
|
||||
|
@ -169,20 +169,20 @@ typedef struct __WIZCHIP
|
|||
{
|
||||
void (*_select) (void); ///< @ref \_WIZCHIP_ selected
|
||||
void (*_deselect)(void); ///< @ref \_WIZCHIP_ deselected
|
||||
}CS;
|
||||
}CS;
|
||||
/**
|
||||
* The set of interface IO callback func.
|
||||
*/
|
||||
union _IF
|
||||
{
|
||||
{
|
||||
/**
|
||||
* For BUS interface IO
|
||||
*/
|
||||
*/
|
||||
struct
|
||||
{
|
||||
uint8_t (*_read_byte) (uint32_t AddrSel);
|
||||
void (*_write_byte) (uint32_t AddrSel, uint8_t wb);
|
||||
}BUS;
|
||||
}BUS;
|
||||
/**
|
||||
* For SPI interface IO
|
||||
*/
|
||||
|
@ -210,13 +210,13 @@ typedef enum
|
|||
CW_CLR_INTERRUPT, ///< Clears interrupt
|
||||
CW_SET_INTRMASK, ///< Masks interrupt
|
||||
CW_GET_INTRMASK, ///< Get interrupt mask
|
||||
CW_SET_INTRTIME, ///< Set interval time between the current and next interrupt.
|
||||
CW_GET_INTRTIME, ///< Set interval time between the current and next interrupt.
|
||||
CW_SET_INTRTIME, ///< Set interval time between the current and next interrupt.
|
||||
CW_GET_INTRTIME, ///< Set interval time between the current and next interrupt.
|
||||
CW_GET_ID, ///< Gets WIZCHIP name.
|
||||
|
||||
#if _WIZCHIP_ == 5500
|
||||
CW_RESET_PHY, ///< Resets internal PHY. Valid Only W5000
|
||||
CW_SET_PHYCONF, ///< When PHY configured by interal register, PHY operation mode (Manual/Auto, 10/100, Half/Full). Valid Only W5000
|
||||
CW_SET_PHYCONF, ///< When PHY configured by interal register, PHY operation mode (Manual/Auto, 10/100, Half/Full). Valid Only W5000
|
||||
CW_GET_PHYCONF, ///< Get PHY operation mode in interal register. Valid Only W5000
|
||||
CW_GET_PHYSTATUS, ///< Get real PHY status on operating. Valid Only W5000
|
||||
CW_SET_PHYPOWMODE, ///< Set PHY power mode as noraml and down when PHYSTATUS.OPMD == 1. Valid Only W5000
|
||||
|
@ -249,13 +249,13 @@ typedef enum
|
|||
{
|
||||
#if _WIZCHIP_ > 5200
|
||||
IK_WOL = (1 << 4), ///< Wake On Lan by receiving the magic packet. Valid in W500.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
IK_PPPOE_TERMINATED = (1 << 5), ///< PPPoE Disconnected
|
||||
|
||||
#if _WIZCHIP_ != 5200
|
||||
IK_DEST_UNREACH = (1 << 6), ///< Destination IP & Port Unreable, No use in W5200
|
||||
#endif
|
||||
#endif
|
||||
|
||||
IK_IP_CONFLICT = (1 << 7), ///< IP conflict occurred
|
||||
|
||||
|
@ -263,22 +263,22 @@ typedef enum
|
|||
IK_SOCK_1 = (1 << 9), ///< Socket 1 interrupt
|
||||
IK_SOCK_2 = (1 << 10), ///< Socket 2 interrupt
|
||||
IK_SOCK_3 = (1 << 11), ///< Socket 3 interrupt
|
||||
#if _WIZCHIP_ > 5100
|
||||
#if _WIZCHIP_ > 5100
|
||||
IK_SOCK_4 = (1 << 12), ///< Socket 4 interrupt, No use in 5100
|
||||
IK_SOCK_5 = (1 << 13), ///< Socket 5 interrupt, No use in 5100
|
||||
IK_SOCK_6 = (1 << 14), ///< Socket 6 interrupt, No use in 5100
|
||||
IK_SOCK_7 = (1 << 15), ///< Socket 7 interrupt, No use in 5100
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if _WIZCHIP_ > 5100
|
||||
IK_SOCK_ALL = (0xFF << 8) ///< All Socket interrpt
|
||||
#else
|
||||
IK_SOCK_ALL = (0x0F << 8) ///< All Socket interrpt
|
||||
#endif
|
||||
IK_SOCK_ALL = (0x0F << 8) ///< All Socket interrpt
|
||||
#endif
|
||||
}intr_kind;
|
||||
|
||||
#define PHY_CONFBY_HW 0 ///< Configured PHY operation mode by HW pin
|
||||
#define PHY_CONFBY_SW 1 ///< Configured PHY operation mode by SW register
|
||||
#define PHY_CONFBY_SW 1 ///< Configured PHY operation mode by SW register
|
||||
#define PHY_MODE_MANUAL 0 ///< Configured PHY operation mode with user setting.
|
||||
#define PHY_MODE_AUTONEGO 1 ///< Configured PHY operation mode with auto-negotiation
|
||||
#define PHY_SPEED_10 0 ///< Link Speed 10
|
||||
|
@ -288,13 +288,13 @@ typedef enum
|
|||
#define PHY_LINK_OFF 0 ///< Link Off
|
||||
#define PHY_LINK_ON 1 ///< Link On
|
||||
#define PHY_POWER_NORM 0 ///< PHY power normal mode
|
||||
#define PHY_POWER_DOWN 1 ///< PHY power down mode
|
||||
#define PHY_POWER_DOWN 1 ///< PHY power down mode
|
||||
|
||||
|
||||
#if _WIZCHIP_ == 5500
|
||||
#if _WIZCHIP_ == 5500
|
||||
/**
|
||||
* @ingroup DATA_TYPE
|
||||
* It configures PHY configuration when CW_SET PHYCONF or CW_GET_PHYCONF in W5500,
|
||||
* It configures PHY configuration when CW_SET PHYCONF or CW_GET_PHYCONF in W5500,
|
||||
* and it indicates the real PHY status configured by HW or SW in all WIZCHIP. \n
|
||||
* Valid only in W5500.
|
||||
*/
|
||||
|
@ -303,11 +303,11 @@ typedef struct wiz_PhyConf_t
|
|||
uint8_t by; ///< set by @ref PHY_CONFBY_HW or @ref PHY_CONFBY_SW
|
||||
uint8_t mode; ///< set by @ref PHY_MODE_MANUAL or @ref PHY_MODE_AUTONEGO
|
||||
uint8_t speed; ///< set by @ref PHY_SPEED_10 or @ref PHY_SPEED_100
|
||||
uint8_t duplex; ///< set by @ref PHY_DUPLEX_HALF @ref PHY_DUPLEX_FULL
|
||||
uint8_t duplex; ///< set by @ref PHY_DUPLEX_HALF @ref PHY_DUPLEX_FULL
|
||||
//uint8_t power; ///< set by @ref PHY_POWER_NORM or @ref PHY_POWER_DOWN
|
||||
//uint8_t link; ///< Valid only in CW_GET_PHYSTATUS. set by @ref PHY_LINK_ON or PHY_DUPLEX_OFF
|
||||
//uint8_t link; ///< Valid only in CW_GET_PHYSTATUS. set by @ref PHY_LINK_ON or PHY_DUPLEX_OFF
|
||||
}wiz_PhyConf;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @ingroup DATA_TYPE
|
||||
|
@ -327,7 +327,7 @@ typedef struct wiz_NetInfo_t
|
|||
{
|
||||
uint8_t mac[6]; ///< Source Mac Address
|
||||
uint8_t ip[4]; ///< Source IP Address
|
||||
uint8_t sn[4]; ///< Subnet Mask
|
||||
uint8_t sn[4]; ///< Subnet Mask
|
||||
uint8_t gw[4]; ///< Gateway IP Address
|
||||
uint8_t dns[4]; ///< DNS server IP Address
|
||||
dhcp_mode dhcp; ///< 1 - Static, 2 - DHCP
|
||||
|
@ -339,10 +339,10 @@ typedef struct wiz_NetInfo_t
|
|||
*/
|
||||
typedef enum
|
||||
{
|
||||
#if _WIZCHIP_ == 5500
|
||||
#if _WIZCHIP_ == 5500
|
||||
NM_FORCEARP = (1<<1), ///< Force to APP send whenever udp data is sent. Valid only in W5500
|
||||
#endif
|
||||
NM_WAKEONLAN = (1<<5), ///< Wake On Lan
|
||||
#endif
|
||||
NM_WAKEONLAN = (1<<5), ///< Wake On Lan
|
||||
NM_PINGBLOCK = (1<<4), ///< Block ping-request
|
||||
NM_PPPOE = (1<<3), ///< PPPoE mode
|
||||
}netmode_type;
|
||||
|
@ -353,7 +353,7 @@ typedef enum
|
|||
*/
|
||||
typedef struct wiz_NetTimeout_t
|
||||
{
|
||||
uint8_t retry_cnt; ///< retry count
|
||||
uint8_t retry_cnt; ///< retry count
|
||||
uint16_t time_100us; ///< time unit 100us
|
||||
}wiz_NetTimeout;
|
||||
|
||||
|
@ -389,8 +389,8 @@ void reg_wizchip_bus_cbfunc(uint8_t (*bus_rb)(uint32_t addr), void (*bus_wb)(uin
|
|||
|
||||
/**
|
||||
*@brief Registers call back function for SPI interface.
|
||||
*@param spi_rb : callback function to read byte usig SPI
|
||||
*@param spi_wb : callback function to write byte usig SPI
|
||||
*@param spi_rb : callback function to read byte usig SPI
|
||||
*@param spi_wb : callback function to write byte usig SPI
|
||||
*@todo Describe \ref wizchip_spi_readbyte and \ref wizchip_spi_writebyte function
|
||||
*or register your functions.
|
||||
*@note If you do not describe or register, null function is called.
|
||||
|
@ -405,8 +405,8 @@ void reg_wizchip_spi_cbfunc(void (*spi_rb)(uint8_t *, uint32_t), void (*spi_wb)(
|
|||
* @param cwtype : Decides to the control type
|
||||
* @param arg : arg type is dependent on cwtype.
|
||||
* @return 0 : Success \n
|
||||
* -1 : Fail because of invalid \ref ctlwizchip_type or unsupported \ref ctlwizchip_type in WIZCHIP
|
||||
*/
|
||||
* -1 : Fail because of invalid \ref ctlwizchip_type or unsupported \ref ctlwizchip_type in WIZCHIP
|
||||
*/
|
||||
int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg);
|
||||
|
||||
/**
|
||||
|
@ -416,20 +416,20 @@ int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg);
|
|||
* @param cntype : Input. Decides to the control type
|
||||
* @param arg : Inout. arg type is dependent on cntype.
|
||||
* @return -1 : Fail because of invalid \ref ctlnetwork_type or unsupported \ref ctlnetwork_type in WIZCHIP \n
|
||||
* 0 : Success
|
||||
*/
|
||||
* 0 : Success
|
||||
*/
|
||||
int8_t ctlnetwork(ctlnetwork_type cntype, void* arg);
|
||||
|
||||
|
||||
/*
|
||||
* The following functions are implemented for internal use.
|
||||
/*
|
||||
* The following functions are implemented for internal use.
|
||||
* but You can call these functions for code size reduction instead of ctlwizchip() and ctlnetwork().
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @ingroup extra_functions
|
||||
* @brief Reset WIZCHIP by softly.
|
||||
*/
|
||||
*/
|
||||
void wizchip_sw_reset(void);
|
||||
|
||||
/**
|
||||
|
@ -442,28 +442,28 @@ void wizchip_sw_reset(void);
|
|||
*/
|
||||
int8_t wizchip_init(uint8_t* txsize, uint8_t* rxsize);
|
||||
|
||||
/**
|
||||
/**
|
||||
* @ingroup extra_functions
|
||||
* @brief Clear Interrupt of WIZCHIP.
|
||||
* @param intr : @ref intr_kind value operated OR. It can type-cast to uint16_t.
|
||||
*/
|
||||
void wizchip_clrinterrupt(intr_kind intr);
|
||||
|
||||
/**
|
||||
/**
|
||||
* @ingroup extra_functions
|
||||
* @brief Get Interrupt of WIZCHIP.
|
||||
* @return @ref intr_kind value operated OR. It can type-cast to uint16_t.
|
||||
*/
|
||||
intr_kind wizchip_getinterrupt(void);
|
||||
|
||||
/**
|
||||
/**
|
||||
* @ingroup extra_functions
|
||||
* @brief Mask or Unmask Interrupt of WIZCHIP.
|
||||
* @param intr : @ref intr_kind value operated OR. It can type-cast to uint16_t.
|
||||
*/
|
||||
void wizchip_setinterruptmask(intr_kind intr);
|
||||
|
||||
/**
|
||||
/**
|
||||
* @ingroup extra_functions
|
||||
* @brief Get Interrupt mask of WIZCHIP.
|
||||
* @return : The operated OR vaule of @ref intr_kind. It can type-cast to uint16_t.
|
||||
|
@ -482,25 +482,25 @@ intr_kind wizchip_getinterruptmask(void);
|
|||
* @brief Set the phy information for WIZCHIP without power mode
|
||||
* @param phyconf : @ref wiz_PhyConf
|
||||
*/
|
||||
void wizphy_setphyconf(wiz_PhyConf* phyconf);
|
||||
void wizphy_setphyconf(wiz_PhyConf* phyconf);
|
||||
/**
|
||||
* @ingroup extra_functions
|
||||
* @brief Get phy configuration information.
|
||||
* @param phyconf : @ref wiz_PhyConf
|
||||
*/
|
||||
void wizphy_getphyconf(wiz_PhyConf* phyconf);
|
||||
void wizphy_getphyconf(wiz_PhyConf* phyconf);
|
||||
/**
|
||||
* @ingroup extra_functions
|
||||
* @brief Get phy status.
|
||||
* @param phyconf : @ref wiz_PhyConf
|
||||
*/
|
||||
*/
|
||||
void wizphy_getphystat(wiz_PhyConf* phyconf);
|
||||
/**
|
||||
* @ingroup extra_functions
|
||||
* @brief set the power mode of phy inside WIZCHIP. Refer to @ref PHYCFGR in W5500, @ref PHYSTATUS in W5200
|
||||
* @param pmode Settig value of power down mode.
|
||||
*/
|
||||
int8_t wizphy_setphypmode(uint8_t pmode);
|
||||
*/
|
||||
int8_t wizphy_setphypmode(uint8_t pmode);
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
@ -523,14 +523,14 @@ uint8_t *wizchip_getsubn(void);
|
|||
|
||||
/**
|
||||
* @ingroup extra_functions
|
||||
* @brief Set the network mode such WOL, PPPoE, Ping Block, and etc.
|
||||
* @brief Set the network mode such WOL, PPPoE, Ping Block, and etc.
|
||||
* @param pnetinfo Value of network mode. Refer to @ref netmode_type.
|
||||
*/
|
||||
int8_t wizchip_setnetmode(netmode_type netmode);
|
||||
|
||||
/**
|
||||
* @ingroup extra_functions
|
||||
* @brief Get the network mode such WOL, PPPoE, Ping Block, and etc.
|
||||
* @brief Get the network mode such WOL, PPPoE, Ping Block, and etc.
|
||||
* @return Value of network mode. Refer to @ref netmode_type.
|
||||
*/
|
||||
netmode_type wizchip_getnetmode(void);
|
||||
|
@ -538,16 +538,16 @@ netmode_type wizchip_getnetmode(void);
|
|||
/**
|
||||
* @ingroup extra_functions
|
||||
* @brief Set retry time value(@ref RTR) and retry count(@ref RCR).
|
||||
* @details @ref RTR configures the retransmission timeout period and @ref RCR configures the number of time of retransmission.
|
||||
* @param nettime @ref RTR value and @ref RCR value. Refer to @ref wiz_NetTimeout.
|
||||
* @details @ref RTR configures the retransmission timeout period and @ref RCR configures the number of time of retransmission.
|
||||
* @param nettime @ref RTR value and @ref RCR value. Refer to @ref wiz_NetTimeout.
|
||||
*/
|
||||
void wizchip_settimeout(wiz_NetTimeout* nettime);
|
||||
|
||||
/**
|
||||
* @ingroup extra_functions
|
||||
* @brief Get retry time value(@ref RTR) and retry count(@ref RCR).
|
||||
* @details @ref RTR configures the retransmission timeout period and @ref RCR configures the number of time of retransmission.
|
||||
* @param nettime @ref RTR value and @ref RCR value. Refer to @ref wiz_NetTimeout.
|
||||
* @details @ref RTR configures the retransmission timeout period and @ref RCR configures the number of time of retransmission.
|
||||
* @param nettime @ref RTR value and @ref RCR value. Refer to @ref wiz_NetTimeout.
|
||||
*/
|
||||
void wizchip_gettimeout(wiz_NetTimeout* nettime);
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
//! <2012/12/20> V1.1.0
|
||||
//! 1. Optimize code
|
||||
//! 2. Add reg_dhcp_cbfunc()
|
||||
//! 3. Add DHCP_stop()
|
||||
//! 3. Add DHCP_stop()
|
||||
//! 4. Integrate check_DHCP_state() & DHCP_run() to DHCP_run()
|
||||
//! 5. Don't care system endian
|
||||
//! 6. Add comments
|
||||
|
@ -22,30 +22,30 @@
|
|||
//!
|
||||
//! Copyright (c) 2013, WIZnet Co., LTD.
|
||||
//! All rights reserved.
|
||||
//!
|
||||
//! Redistribution and use in source and binary forms, with or without
|
||||
//! modification, are permitted provided that the following conditions
|
||||
//! are met:
|
||||
//!
|
||||
//! * Redistributions of source code must retain the above copyright
|
||||
//! notice, this list of conditions and the following disclaimer.
|
||||
//!
|
||||
//! Redistribution and use in source and binary forms, with or without
|
||||
//! modification, are permitted provided that the following conditions
|
||||
//! are met:
|
||||
//!
|
||||
//! * Redistributions of source code must retain the above copyright
|
||||
//! notice, this list of conditions and the following disclaimer.
|
||||
//! * Redistributions in binary form must reproduce the above copyright
|
||||
//! notice, this list of conditions and the following disclaimer in the
|
||||
//! documentation and/or other materials provided with the distribution.
|
||||
//! * Neither the name of the <ORGANIZATION> nor the names of its
|
||||
//! contributors may be used to endorse or promote products derived
|
||||
//! from this software without specific prior written permission.
|
||||
//!
|
||||
//! documentation and/or other materials provided with the distribution.
|
||||
//! * Neither the name of the <ORGANIZATION> nor the names of its
|
||||
//! contributors may be used to endorse or promote products derived
|
||||
//! from this software without specific prior written permission.
|
||||
//!
|
||||
//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
//! AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
//! AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
//! IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
//! ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
//! LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
//! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
//! ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
//! LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
//! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
//! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
//! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
//! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
//! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
//! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
//! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
//! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
//! THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
@ -59,7 +59,7 @@
|
|||
|
||||
#ifdef _DHCP_DEBUG_
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* DHCP state machine. */
|
||||
#define STATE_DHCP_INIT 0 ///< Initialize
|
||||
|
@ -70,7 +70,7 @@
|
|||
#define STATE_DHCP_RELEASE 5 ///< No use
|
||||
#define STATE_DHCP_STOP 6 ///< Stop processing DHCP
|
||||
|
||||
#define DHCP_FLAGSBROADCAST 0x8000 ///< The broadcast value of flags in @ref RIP_MSG
|
||||
#define DHCP_FLAGSBROADCAST 0x8000 ///< The broadcast value of flags in @ref RIP_MSG
|
||||
#define DHCP_FLAGSUNICAST 0x0000 ///< The unicast value of flags in @ref RIP_MSG
|
||||
|
||||
/* DHCP message OP code */
|
||||
|
@ -99,7 +99,7 @@
|
|||
#define OPT_SIZE 312 /// Max OPT size of @ref RIP_MSG
|
||||
#define RIP_MSG_SIZE (236+OPT_SIZE) /// Max size of @ref RIP_MSG
|
||||
|
||||
/*
|
||||
/*
|
||||
* @brief DHCP option and value (cf. RFC1533)
|
||||
*/
|
||||
enum
|
||||
|
@ -171,7 +171,7 @@ enum
|
|||
|
||||
/*
|
||||
* @brief DHCP message format
|
||||
*/
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t op; ///< @ref DHCP_BOOTREQUEST or @ref DHCP_BOOTREPLY
|
||||
uint8_t htype; ///< @ref DHCP_HTYPE10MB or @ref DHCP_HTYPE100MB
|
||||
|
@ -182,7 +182,7 @@ typedef struct {
|
|||
uint16_t flags; ///< @ref DHCP_FLAGSBROADCAST or @ref DHCP_FLAGSUNICAST
|
||||
uint8_t ciaddr[4]; ///< @ref Request IP to DHCP sever
|
||||
uint8_t yiaddr[4]; ///< @ref Offered IP from DHCP server
|
||||
uint8_t siaddr[4]; ///< No use
|
||||
uint8_t siaddr[4]; ///< No use
|
||||
uint8_t giaddr[4]; ///< No use
|
||||
uint8_t chaddr[16]; ///< DHCP client 6bytes MAC address. Others is filled to zero
|
||||
uint8_t sname[64]; ///< No use
|
||||
|
@ -205,7 +205,7 @@ uint8_t DHCP_allocated_dns[4] = {0, }; // DNS address from DHCP
|
|||
|
||||
|
||||
int8_t dhcp_state = STATE_DHCP_INIT; // DHCP state
|
||||
int8_t dhcp_retry_count = 0;
|
||||
int8_t dhcp_retry_count = 0;
|
||||
|
||||
uint32_t dhcp_lease_time = INFINITE_LEASETIME;
|
||||
volatile uint32_t dhcp_tick_1s = 0; // unit 1 second
|
||||
|
@ -215,7 +215,7 @@ uint32_t DHCP_XID; // Any number
|
|||
|
||||
RIP_MSG* pDHCPMSG; // Buffer pointer for DHCP processing
|
||||
|
||||
uint8_t HOST_NAME[] = DCHP_HOST_NAME;
|
||||
uint8_t HOST_NAME[] = DCHP_HOST_NAME;
|
||||
|
||||
uint8_t DHCP_CHADDR[6]; // DHCP Client MAC address.
|
||||
|
||||
|
@ -306,9 +306,9 @@ void makeDHCPMSG(void)
|
|||
*(ptmp+0) = (uint8_t)((DHCP_XID & 0xFF000000) >> 24);
|
||||
*(ptmp+1) = (uint8_t)((DHCP_XID & 0x00FF0000) >> 16);
|
||||
*(ptmp+2) = (uint8_t)((DHCP_XID & 0x0000FF00) >> 8);
|
||||
*(ptmp+3) = (uint8_t)((DHCP_XID & 0x000000FF) >> 0);
|
||||
*(ptmp+3) = (uint8_t)((DHCP_XID & 0x000000FF) >> 0);
|
||||
pDHCPMSG->secs = DHCP_SECS;
|
||||
ptmp = (uint8_t*)(&pDHCPMSG->flags);
|
||||
ptmp = (uint8_t*)(&pDHCPMSG->flags);
|
||||
*(ptmp+0) = (uint8_t)((DHCP_FLAGSBROADCAST & 0xFF00) >> 8);
|
||||
*(ptmp+1) = (uint8_t)((DHCP_FLAGSBROADCAST & 0x00FF) >> 0);
|
||||
|
||||
|
@ -356,16 +356,16 @@ void send_DHCP_DISCOVER(void)
|
|||
uint16_t i;
|
||||
uint8_t ip[4];
|
||||
uint16_t k = 0;
|
||||
|
||||
|
||||
makeDHCPMSG();
|
||||
|
||||
k = 4; // because MAGIC_COOKIE already made by makeDHCPMSG()
|
||||
|
||||
|
||||
// Option Request Param
|
||||
pDHCPMSG->OPT[k++] = dhcpMessageType;
|
||||
pDHCPMSG->OPT[k++] = 0x01;
|
||||
pDHCPMSG->OPT[k++] = DHCP_DISCOVER;
|
||||
|
||||
|
||||
// Client identifier
|
||||
pDHCPMSG->OPT[k++] = dhcpClientIdentifier;
|
||||
pDHCPMSG->OPT[k++] = 0x07;
|
||||
|
@ -376,10 +376,10 @@ void send_DHCP_DISCOVER(void)
|
|||
pDHCPMSG->OPT[k++] = DHCP_CHADDR[3];
|
||||
pDHCPMSG->OPT[k++] = DHCP_CHADDR[4];
|
||||
pDHCPMSG->OPT[k++] = DHCP_CHADDR[5];
|
||||
|
||||
|
||||
// host name
|
||||
pDHCPMSG->OPT[k++] = hostName;
|
||||
pDHCPMSG->OPT[k++] = 0; // fill zero length of hostname
|
||||
pDHCPMSG->OPT[k++] = 0; // fill zero length of hostname
|
||||
for(i = 0 ; HOST_NAME[i] != 0; i++)
|
||||
pDHCPMSG->OPT[k++] = HOST_NAME[i];
|
||||
pDHCPMSG->OPT[k++] = DHCP_CHADDR[3];
|
||||
|
@ -432,18 +432,18 @@ void send_DHCP_REQUEST(void)
|
|||
ip[0] = DHCP_SIP[0];
|
||||
ip[1] = DHCP_SIP[1];
|
||||
ip[2] = DHCP_SIP[2];
|
||||
ip[3] = DHCP_SIP[3];
|
||||
ip[3] = DHCP_SIP[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
ip[0] = 255;
|
||||
ip[1] = 255;
|
||||
ip[2] = 255;
|
||||
ip[3] = 255;
|
||||
ip[3] = 255;
|
||||
}
|
||||
|
||||
|
||||
k = 4; // because MAGIC_COOKIE already made by makeDHCPMSG()
|
||||
|
||||
|
||||
// Option Request Param.
|
||||
pDHCPMSG->OPT[k++] = dhcpMessageType;
|
||||
pDHCPMSG->OPT[k++] = 0x01;
|
||||
|
@ -467,7 +467,7 @@ void send_DHCP_REQUEST(void)
|
|||
pDHCPMSG->OPT[k++] = DHCP_allocated_ip[1];
|
||||
pDHCPMSG->OPT[k++] = DHCP_allocated_ip[2];
|
||||
pDHCPMSG->OPT[k++] = DHCP_allocated_ip[3];
|
||||
|
||||
|
||||
pDHCPMSG->OPT[k++] = dhcpServerIdentifier;
|
||||
pDHCPMSG->OPT[k++] = 0x04;
|
||||
pDHCPMSG->OPT[k++] = DHCP_SIP[0];
|
||||
|
@ -485,7 +485,7 @@ void send_DHCP_REQUEST(void)
|
|||
pDHCPMSG->OPT[k++] = DHCP_CHADDR[4];
|
||||
pDHCPMSG->OPT[k++] = DHCP_CHADDR[5];
|
||||
pDHCPMSG->OPT[k - (i+3+1)] = i+3; // length of hostname
|
||||
|
||||
|
||||
pDHCPMSG->OPT[k++] = dhcpParamRequest;
|
||||
pDHCPMSG->OPT[k++] = 0x08;
|
||||
pDHCPMSG->OPT[k++] = subnetMask;
|
||||
|
@ -503,7 +503,7 @@ void send_DHCP_REQUEST(void)
|
|||
#ifdef _DHCP_DEBUG_
|
||||
printf("> Send DHCP_REQUEST\r\n");
|
||||
#endif
|
||||
|
||||
|
||||
WIZCHIP_EXPORT(sendto)(DHCP_SOCKET, (uint8_t *)pDHCPMSG, RIP_MSG_SIZE, ip, DHCP_SERVER_PORT);
|
||||
|
||||
}
|
||||
|
@ -514,11 +514,11 @@ void send_DHCP_DECLINE(void)
|
|||
int i;
|
||||
uint8_t ip[4];
|
||||
uint16_t k = 0;
|
||||
|
||||
|
||||
makeDHCPMSG();
|
||||
|
||||
k = 4; // because MAGIC_COOKIE already made by makeDHCPMSG()
|
||||
|
||||
|
||||
*((uint8_t*)(&pDHCPMSG->flags)) = ((DHCP_FLAGSUNICAST & 0xFF00)>> 8);
|
||||
*((uint8_t*)(&pDHCPMSG->flags)+1) = (DHCP_FLAGSUNICAST & 0x00FF);
|
||||
|
||||
|
@ -577,15 +577,15 @@ int8_t parseDHCPMSG(void)
|
|||
|
||||
uint8_t * p;
|
||||
uint8_t * e;
|
||||
uint8_t type;
|
||||
uint8_t type = 0;
|
||||
uint8_t opt_len;
|
||||
|
||||
|
||||
if((len = getSn_RX_RSR(DHCP_SOCKET)) > 0)
|
||||
{
|
||||
len = WIZCHIP_EXPORT(recvfrom)(DHCP_SOCKET, (uint8_t *)pDHCPMSG, len, svr_addr, &svr_port);
|
||||
#ifdef _DHCP_DEBUG_
|
||||
#ifdef _DHCP_DEBUG_
|
||||
printf("DHCP message : %d.%d.%d.%d(%d) %d received. \r\n",svr_addr[0],svr_addr[1],svr_addr[2], svr_addr[3],svr_port, len);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
else return 0;
|
||||
if (svr_port == DHCP_SERVER_PORT) {
|
||||
|
@ -624,7 +624,7 @@ int8_t parseDHCPMSG(void)
|
|||
break;
|
||||
case routersOnSubnet :
|
||||
p++;
|
||||
opt_len = *p++;
|
||||
opt_len = *p++;
|
||||
DHCP_allocated_gw[0] = *p++;
|
||||
DHCP_allocated_gw[1] = *p++;
|
||||
DHCP_allocated_gw[2] = *p++;
|
||||
|
@ -632,8 +632,8 @@ int8_t parseDHCPMSG(void)
|
|||
p = p + (opt_len - 4);
|
||||
break;
|
||||
case dns :
|
||||
p++;
|
||||
opt_len = *p++;
|
||||
p++;
|
||||
opt_len = *p++;
|
||||
DHCP_allocated_dns[0] = *p++;
|
||||
DHCP_allocated_dns[1] = *p++;
|
||||
DHCP_allocated_dns[2] = *p++;
|
||||
|
@ -647,7 +647,7 @@ int8_t parseDHCPMSG(void)
|
|||
dhcp_lease_time = (dhcp_lease_time << 8) + *p++;
|
||||
dhcp_lease_time = (dhcp_lease_time << 8) + *p++;
|
||||
dhcp_lease_time = (dhcp_lease_time << 8) + *p++;
|
||||
#ifdef _DHCP_DEBUG_
|
||||
#ifdef _DHCP_DEBUG_
|
||||
dhcp_lease_time = 10;
|
||||
#endif
|
||||
break;
|
||||
|
@ -740,7 +740,7 @@ uint8_t DHCP_run(void)
|
|||
case STATE_DHCP_LEASED :
|
||||
ret = DHCP_IP_LEASED;
|
||||
if ((dhcp_lease_time != INFINITE_LEASETIME) && ((dhcp_lease_time/2) < dhcp_tick_1s)) {
|
||||
|
||||
|
||||
#ifdef _DHCP_DEBUG_
|
||||
printf("> Maintains the IP address \r\n");
|
||||
#endif
|
||||
|
@ -750,7 +750,7 @@ uint8_t DHCP_run(void)
|
|||
OLD_allocated_ip[1] = DHCP_allocated_ip[1];
|
||||
OLD_allocated_ip[2] = DHCP_allocated_ip[2];
|
||||
OLD_allocated_ip[3] = DHCP_allocated_ip[3];
|
||||
|
||||
|
||||
DHCP_XID++;
|
||||
|
||||
send_DHCP_REQUEST();
|
||||
|
@ -765,21 +765,21 @@ uint8_t DHCP_run(void)
|
|||
ret = DHCP_IP_LEASED;
|
||||
if (type == DHCP_ACK) {
|
||||
dhcp_retry_count = 0;
|
||||
if (OLD_allocated_ip[0] != DHCP_allocated_ip[0] ||
|
||||
if (OLD_allocated_ip[0] != DHCP_allocated_ip[0] ||
|
||||
OLD_allocated_ip[1] != DHCP_allocated_ip[1] ||
|
||||
OLD_allocated_ip[2] != DHCP_allocated_ip[2] ||
|
||||
OLD_allocated_ip[3] != DHCP_allocated_ip[3])
|
||||
OLD_allocated_ip[3] != DHCP_allocated_ip[3])
|
||||
{
|
||||
ret = DHCP_IP_CHANGED;
|
||||
dhcp_ip_update();
|
||||
#ifdef _DHCP_DEBUG_
|
||||
printf(">IP changed.\r\n");
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
#ifdef _DHCP_DEBUG_
|
||||
else printf(">IP is continued.\r\n");
|
||||
#endif
|
||||
#endif
|
||||
reset_DHCP_timeout();
|
||||
dhcp_state = STATE_DHCP_LEASED;
|
||||
} else if (type == DHCP_NAK) {
|
||||
|
@ -809,7 +809,7 @@ void DHCP_stop(void)
|
|||
uint8_t check_DHCP_timeout(void)
|
||||
{
|
||||
uint8_t ret = DHCP_RUNNING;
|
||||
|
||||
|
||||
if (dhcp_retry_count < MAX_DHCP_RETRY) {
|
||||
if (dhcp_tick_next < dhcp_tick_1s) {
|
||||
|
||||
|
@ -818,7 +818,7 @@ uint8_t check_DHCP_timeout(void)
|
|||
// printf("<<timeout>> state : STATE_DHCP_DISCOVER\r\n");
|
||||
send_DHCP_DISCOVER();
|
||||
break;
|
||||
|
||||
|
||||
case STATE_DHCP_REQUEST :
|
||||
// printf("<<timeout>> state : STATE_DHCP_REQUEST\r\n");
|
||||
|
||||
|
@ -827,10 +827,10 @@ uint8_t check_DHCP_timeout(void)
|
|||
|
||||
case STATE_DHCP_REREQUEST :
|
||||
// printf("<<timeout>> state : STATE_DHCP_REREQUEST\r\n");
|
||||
|
||||
|
||||
send_DHCP_REQUEST();
|
||||
break;
|
||||
|
||||
|
||||
default :
|
||||
break;
|
||||
}
|
||||
|
@ -892,7 +892,7 @@ int8_t check_DHCP_leasedIP(void)
|
|||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DHCP_init(uint8_t s, DHCP_INIT_BUFFER_TYPE* buf)
|
||||
{
|
||||
|
@ -903,11 +903,11 @@ void DHCP_init(uint8_t s, DHCP_INIT_BUFFER_TYPE* buf)
|
|||
// assign temporary mac address, you should be set SHAR before call this function.
|
||||
DHCP_CHADDR[0] = 0x00;
|
||||
DHCP_CHADDR[1] = 0x08;
|
||||
DHCP_CHADDR[2] = 0xdc;
|
||||
DHCP_CHADDR[2] = 0xdc;
|
||||
DHCP_CHADDR[3] = 0x00;
|
||||
DHCP_CHADDR[4] = 0x00;
|
||||
DHCP_CHADDR[5] = 0x00;
|
||||
setSHAR(DHCP_CHADDR);
|
||||
DHCP_CHADDR[5] = 0x00;
|
||||
setSHAR(DHCP_CHADDR);
|
||||
}
|
||||
|
||||
DHCP_SOCKET = s; // SOCK_DHCP
|
||||
|
@ -941,7 +941,7 @@ void getIPfromDHCP(uint8_t* ip)
|
|||
{
|
||||
ip[0] = DHCP_allocated_ip[0];
|
||||
ip[1] = DHCP_allocated_ip[1];
|
||||
ip[2] = DHCP_allocated_ip[2];
|
||||
ip[2] = DHCP_allocated_ip[2];
|
||||
ip[3] = DHCP_allocated_ip[3];
|
||||
}
|
||||
|
||||
|
@ -950,7 +950,7 @@ void getGWfromDHCP(uint8_t* ip)
|
|||
ip[0] =DHCP_allocated_gw[0];
|
||||
ip[1] =DHCP_allocated_gw[1];
|
||||
ip[2] =DHCP_allocated_gw[2];
|
||||
ip[3] =DHCP_allocated_gw[3];
|
||||
ip[3] =DHCP_allocated_gw[3];
|
||||
}
|
||||
|
||||
void getSNfromDHCP(uint8_t* ip)
|
||||
|
@ -958,7 +958,7 @@ void getSNfromDHCP(uint8_t* ip)
|
|||
ip[0] = DHCP_allocated_sn[0];
|
||||
ip[1] = DHCP_allocated_sn[1];
|
||||
ip[2] = DHCP_allocated_sn[2];
|
||||
ip[3] = DHCP_allocated_sn[3];
|
||||
ip[3] = DHCP_allocated_sn[3];
|
||||
}
|
||||
|
||||
void getDNSfromDHCP(uint8_t* ip)
|
||||
|
@ -966,14 +966,10 @@ void getDNSfromDHCP(uint8_t* ip)
|
|||
ip[0] = DHCP_allocated_dns[0];
|
||||
ip[1] = DHCP_allocated_dns[1];
|
||||
ip[2] = DHCP_allocated_dns[2];
|
||||
ip[3] = DHCP_allocated_dns[3];
|
||||
ip[3] = DHCP_allocated_dns[3];
|
||||
}
|
||||
|
||||
uint32_t getDHCPLeasetime(void)
|
||||
{
|
||||
return dhcp_lease_time;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -15,30 +15,30 @@
|
|||
//!
|
||||
//! Copyright (c) 2013, WIZnet Co., LTD.
|
||||
//! All rights reserved.
|
||||
//!
|
||||
//! Redistribution and use in source and binary forms, with or without
|
||||
//! modification, are permitted provided that the following conditions
|
||||
//! are met:
|
||||
//!
|
||||
//! * Redistributions of source code must retain the above copyright
|
||||
//! notice, this list of conditions and the following disclaimer.
|
||||
//!
|
||||
//! Redistribution and use in source and binary forms, with or without
|
||||
//! modification, are permitted provided that the following conditions
|
||||
//! are met:
|
||||
//!
|
||||
//! * Redistributions of source code must retain the above copyright
|
||||
//! notice, this list of conditions and the following disclaimer.
|
||||
//! * Redistributions in binary form must reproduce the above copyright
|
||||
//! notice, this list of conditions and the following disclaimer in the
|
||||
//! documentation and/or other materials provided with the distribution.
|
||||
//! * Neither the name of the <ORGANIZATION> nor the names of its
|
||||
//! contributors may be used to endorse or promote products derived
|
||||
//! from this software without specific prior written permission.
|
||||
//!
|
||||
//! documentation and/or other materials provided with the distribution.
|
||||
//! * Neither the name of the <ORGANIZATION> nor the names of its
|
||||
//! contributors may be used to endorse or promote products derived
|
||||
//! from this software without specific prior written permission.
|
||||
//!
|
||||
//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
//! AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
//! AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
//! IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
//! ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
//! LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
//! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
//! ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
//! LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
//! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
//! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
//! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
//! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
//! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
//! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
//! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
//! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
//! THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
@ -46,7 +46,7 @@
|
|||
#define _DHCP_H_
|
||||
|
||||
/*
|
||||
* @brief
|
||||
* @brief
|
||||
* @details If you want to display debug & processing message, Define _DHCP_DEBUG_
|
||||
* @note If defined, it depends on <stdio.h>
|
||||
*/
|
||||
|
@ -65,7 +65,7 @@
|
|||
|
||||
#define DCHP_HOST_NAME "WIZnet\0"
|
||||
|
||||
/*
|
||||
/*
|
||||
* @brief return value of @ref DHCP_run()
|
||||
*/
|
||||
enum
|
||||
|
@ -74,7 +74,7 @@ enum
|
|||
DHCP_RUNNING, ///< Processing DHCP protocol
|
||||
DHCP_IP_ASSIGN, ///< First Occupy IP from DHPC server (if cbfunc == null, act as default default_ip_assign)
|
||||
DHCP_IP_CHANGED, ///< Change IP address by new IP address from DHCP (if cbfunc == null, act as default default_ip_update)
|
||||
DHCP_IP_LEASED, ///< Stand by
|
||||
DHCP_IP_LEASED, ///< Stand by
|
||||
DHCP_STOPPED ///< Stop processing DHCP protocol
|
||||
};
|
||||
|
||||
|
@ -89,12 +89,12 @@ void DHCP_init(uint8_t s, DHCP_INIT_BUFFER_TYPE* buf);
|
|||
|
||||
/*
|
||||
* @brief DHCP 1s Tick Timer handler
|
||||
* @note SHOULD BE register to your system 1s Tick timer handler
|
||||
* @note SHOULD BE register to your system 1s Tick timer handler
|
||||
*/
|
||||
void DHCP_time_handler(void);
|
||||
|
||||
/*
|
||||
* @brief Register call back function
|
||||
/*
|
||||
* @brief Register call back function
|
||||
* @param ip_assign - callback func when IP is assigned from DHCP server first
|
||||
* @param ip_update - callback func when IP is changed
|
||||
* @prarm ip_conflict - callback func when the assigned IP is conflict with others.
|
||||
|
@ -112,13 +112,13 @@ void reg_dhcp_cbfunc(void(*ip_assign)(void), void(*ip_update)(void), void(*ip_co
|
|||
* @ref DHCP_STOPPED \n
|
||||
*
|
||||
* @note This function is always called by you main task.
|
||||
*/
|
||||
*/
|
||||
uint8_t DHCP_run(void);
|
||||
|
||||
/*
|
||||
* @brief Stop DHCP processing
|
||||
* @note If you want to restart. call DHCP_init() and DHCP_run()
|
||||
*/
|
||||
*/
|
||||
void DHCP_stop(void);
|
||||
|
||||
/* Get Network information assigned from DHCP server */
|
||||
|
|
|
@ -22,37 +22,37 @@
|
|||
//!
|
||||
//! Copyright (c) 2013, WIZnet Co., LTD.
|
||||
//! All rights reserved.
|
||||
//!
|
||||
//! Redistribution and use in source and binary forms, with or without
|
||||
//! modification, are permitted provided that the following conditions
|
||||
//! are met:
|
||||
//!
|
||||
//! * Redistributions of source code must retain the above copyright
|
||||
//! notice, this list of conditions and the following disclaimer.
|
||||
//!
|
||||
//! Redistribution and use in source and binary forms, with or without
|
||||
//! modification, are permitted provided that the following conditions
|
||||
//! are met:
|
||||
//!
|
||||
//! * Redistributions of source code must retain the above copyright
|
||||
//! notice, this list of conditions and the following disclaimer.
|
||||
//! * Redistributions in binary form must reproduce the above copyright
|
||||
//! notice, this list of conditions and the following disclaimer in the
|
||||
//! documentation and/or other materials provided with the distribution.
|
||||
//! * Neither the name of the <ORGANIZATION> nor the names of its
|
||||
//! contributors may be used to endorse or promote products derived
|
||||
//! from this software without specific prior written permission.
|
||||
//!
|
||||
//! documentation and/or other materials provided with the distribution.
|
||||
//! * Neither the name of the <ORGANIZATION> nor the names of its
|
||||
//! contributors may be used to endorse or promote products derived
|
||||
//! from this software without specific prior written permission.
|
||||
//!
|
||||
//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
//! AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
//! AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
//! IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
//! ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
//! LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
//! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
//! ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
//! LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
//! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
//! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
//! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
//! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
//! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
//! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
//! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
//! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
//! THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "tick.h"
|
||||
#include "supervisor/shared/tick.h"
|
||||
|
||||
//#include "Ethernet/socket.h"
|
||||
//#include "Internet/DNS/dns.h"
|
||||
|
@ -125,7 +125,7 @@ uint16_t DNS_MSGID; // DNS message ID
|
|||
|
||||
|
||||
uint32_t HAL_GetTick(void) {
|
||||
return ticks_ms;
|
||||
return supervisor_ticks_ms32();
|
||||
}
|
||||
|
||||
uint32_t hal_sys_tick;
|
||||
|
@ -338,7 +338,7 @@ uint8_t * dns_answer(uint8_t * msg, uint8_t * cp, uint8_t * ip_from_dns)
|
|||
* len - is the size of reply message.
|
||||
* Returns : -1 - Domain name length is too big
|
||||
* 0 - Fail (Timeout or parse error)
|
||||
* 1 - Success,
|
||||
* 1 - Success,
|
||||
*/
|
||||
int8_t parseDNSMSG(struct dhdr * pdhdr, uint8_t * pbuf, uint8_t * ip_from_dns)
|
||||
{
|
||||
|
@ -525,7 +525,7 @@ int8_t DNS_run(uint8_t * dns_ip, uint8_t * name, uint8_t * ip_from_dns)
|
|||
int8_t ret_check_timeout;
|
||||
|
||||
hal_sys_tick = HAL_GetTick();
|
||||
|
||||
|
||||
// Socket open
|
||||
WIZCHIP_EXPORT(socket)(DNS_SOCKET, Sn_MR_UDP, 0, 0);
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
//
|
||||
//! \file dns.h
|
||||
//! \brief DNS APIs Header file.
|
||||
//! \details Send DNS query & Receive DNS reponse.
|
||||
//! \details Send DNS query & Receive DNS reponse.
|
||||
//! \version 1.1.0
|
||||
//! \date 2013/11/18
|
||||
//! \par Revision history
|
||||
|
@ -20,30 +20,30 @@
|
|||
//!
|
||||
//! Copyright (c) 2013, WIZnet Co., LTD.
|
||||
//! All rights reserved.
|
||||
//!
|
||||
//! Redistribution and use in source and binary forms, with or without
|
||||
//! modification, are permitted provided that the following conditions
|
||||
//! are met:
|
||||
//!
|
||||
//! * Redistributions of source code must retain the above copyright
|
||||
//! notice, this list of conditions and the following disclaimer.
|
||||
//!
|
||||
//! Redistribution and use in source and binary forms, with or without
|
||||
//! modification, are permitted provided that the following conditions
|
||||
//! are met:
|
||||
//!
|
||||
//! * Redistributions of source code must retain the above copyright
|
||||
//! notice, this list of conditions and the following disclaimer.
|
||||
//! * Redistributions in binary form must reproduce the above copyright
|
||||
//! notice, this list of conditions and the following disclaimer in the
|
||||
//! documentation and/or other materials provided with the distribution.
|
||||
//! * Neither the name of the <ORGANIZATION> nor the names of its
|
||||
//! contributors may be used to endorse or promote products derived
|
||||
//! from this software without specific prior written permission.
|
||||
//!
|
||||
//! documentation and/or other materials provided with the distribution.
|
||||
//! * Neither the name of the <ORGANIZATION> nor the names of its
|
||||
//! contributors may be used to endorse or promote products derived
|
||||
//! from this software without specific prior written permission.
|
||||
//!
|
||||
//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
//! AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
//! AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
//! IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
//! ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
//! LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
//! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
//! ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
//! LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
//! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
//! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
//! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
//! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
//! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
//! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
//! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
//! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
//! THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
|
|
@ -0,0 +1,128 @@
|
|||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2013, 2014 Damien P. George
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
#ifndef MICROPY_INCLUDED_STM32_FONT_PETME128_8X8_H
|
||||
#define MICROPY_INCLUDED_STM32_FONT_PETME128_8X8_H
|
||||
|
||||
static const uint8_t font_petme128_8x8[] = {
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // 32=
|
||||
0x00,0x00,0x00,0x4f,0x4f,0x00,0x00,0x00, // 33=!
|
||||
0x00,0x07,0x07,0x00,0x00,0x07,0x07,0x00, // 34="
|
||||
0x14,0x7f,0x7f,0x14,0x14,0x7f,0x7f,0x14, // 35=#
|
||||
0x00,0x24,0x2e,0x6b,0x6b,0x3a,0x12,0x00, // 36=$
|
||||
0x00,0x63,0x33,0x18,0x0c,0x66,0x63,0x00, // 37=%
|
||||
0x00,0x32,0x7f,0x4d,0x4d,0x77,0x72,0x50, // 38=&
|
||||
0x00,0x00,0x00,0x04,0x06,0x03,0x01,0x00, // 39='
|
||||
0x00,0x00,0x1c,0x3e,0x63,0x41,0x00,0x00, // 40=(
|
||||
0x00,0x00,0x41,0x63,0x3e,0x1c,0x00,0x00, // 41=)
|
||||
0x08,0x2a,0x3e,0x1c,0x1c,0x3e,0x2a,0x08, // 42=*
|
||||
0x00,0x08,0x08,0x3e,0x3e,0x08,0x08,0x00, // 43=+
|
||||
0x00,0x00,0x80,0xe0,0x60,0x00,0x00,0x00, // 44=,
|
||||
0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x00, // 45=-
|
||||
0x00,0x00,0x00,0x60,0x60,0x00,0x00,0x00, // 46=.
|
||||
0x00,0x40,0x60,0x30,0x18,0x0c,0x06,0x02, // 47=/
|
||||
0x00,0x3e,0x7f,0x49,0x45,0x7f,0x3e,0x00, // 48=0
|
||||
0x00,0x40,0x44,0x7f,0x7f,0x40,0x40,0x00, // 49=1
|
||||
0x00,0x62,0x73,0x51,0x49,0x4f,0x46,0x00, // 50=2
|
||||
0x00,0x22,0x63,0x49,0x49,0x7f,0x36,0x00, // 51=3
|
||||
0x00,0x18,0x18,0x14,0x16,0x7f,0x7f,0x10, // 52=4
|
||||
0x00,0x27,0x67,0x45,0x45,0x7d,0x39,0x00, // 53=5
|
||||
0x00,0x3e,0x7f,0x49,0x49,0x7b,0x32,0x00, // 54=6
|
||||
0x00,0x03,0x03,0x79,0x7d,0x07,0x03,0x00, // 55=7
|
||||
0x00,0x36,0x7f,0x49,0x49,0x7f,0x36,0x00, // 56=8
|
||||
0x00,0x26,0x6f,0x49,0x49,0x7f,0x3e,0x00, // 57=9
|
||||
0x00,0x00,0x00,0x24,0x24,0x00,0x00,0x00, // 58=:
|
||||
0x00,0x00,0x80,0xe4,0x64,0x00,0x00,0x00, // 59=;
|
||||
0x00,0x08,0x1c,0x36,0x63,0x41,0x41,0x00, // 60=<
|
||||
0x00,0x14,0x14,0x14,0x14,0x14,0x14,0x00, // 61==
|
||||
0x00,0x41,0x41,0x63,0x36,0x1c,0x08,0x00, // 62=>
|
||||
0x00,0x02,0x03,0x51,0x59,0x0f,0x06,0x00, // 63=?
|
||||
0x00,0x3e,0x7f,0x41,0x4d,0x4f,0x2e,0x00, // 64=@
|
||||
0x00,0x7c,0x7e,0x0b,0x0b,0x7e,0x7c,0x00, // 65=A
|
||||
0x00,0x7f,0x7f,0x49,0x49,0x7f,0x36,0x00, // 66=B
|
||||
0x00,0x3e,0x7f,0x41,0x41,0x63,0x22,0x00, // 67=C
|
||||
0x00,0x7f,0x7f,0x41,0x63,0x3e,0x1c,0x00, // 68=D
|
||||
0x00,0x7f,0x7f,0x49,0x49,0x41,0x41,0x00, // 69=E
|
||||
0x00,0x7f,0x7f,0x09,0x09,0x01,0x01,0x00, // 70=F
|
||||
0x00,0x3e,0x7f,0x41,0x49,0x7b,0x3a,0x00, // 71=G
|
||||
0x00,0x7f,0x7f,0x08,0x08,0x7f,0x7f,0x00, // 72=H
|
||||
0x00,0x00,0x41,0x7f,0x7f,0x41,0x00,0x00, // 73=I
|
||||
0x00,0x20,0x60,0x41,0x7f,0x3f,0x01,0x00, // 74=J
|
||||
0x00,0x7f,0x7f,0x1c,0x36,0x63,0x41,0x00, // 75=K
|
||||
0x00,0x7f,0x7f,0x40,0x40,0x40,0x40,0x00, // 76=L
|
||||
0x00,0x7f,0x7f,0x06,0x0c,0x06,0x7f,0x7f, // 77=M
|
||||
0x00,0x7f,0x7f,0x0e,0x1c,0x7f,0x7f,0x00, // 78=N
|
||||
0x00,0x3e,0x7f,0x41,0x41,0x7f,0x3e,0x00, // 79=O
|
||||
0x00,0x7f,0x7f,0x09,0x09,0x0f,0x06,0x00, // 80=P
|
||||
0x00,0x1e,0x3f,0x21,0x61,0x7f,0x5e,0x00, // 81=Q
|
||||
0x00,0x7f,0x7f,0x19,0x39,0x6f,0x46,0x00, // 82=R
|
||||
0x00,0x26,0x6f,0x49,0x49,0x7b,0x32,0x00, // 83=S
|
||||
0x00,0x01,0x01,0x7f,0x7f,0x01,0x01,0x00, // 84=T
|
||||
0x00,0x3f,0x7f,0x40,0x40,0x7f,0x3f,0x00, // 85=U
|
||||
0x00,0x1f,0x3f,0x60,0x60,0x3f,0x1f,0x00, // 86=V
|
||||
0x00,0x7f,0x7f,0x30,0x18,0x30,0x7f,0x7f, // 87=W
|
||||
0x00,0x63,0x77,0x1c,0x1c,0x77,0x63,0x00, // 88=X
|
||||
0x00,0x07,0x0f,0x78,0x78,0x0f,0x07,0x00, // 89=Y
|
||||
0x00,0x61,0x71,0x59,0x4d,0x47,0x43,0x00, // 90=Z
|
||||
0x00,0x00,0x7f,0x7f,0x41,0x41,0x00,0x00, // 91=[
|
||||
0x00,0x02,0x06,0x0c,0x18,0x30,0x60,0x40, // 92='\'
|
||||
0x00,0x00,0x41,0x41,0x7f,0x7f,0x00,0x00, // 93=]
|
||||
0x00,0x08,0x0c,0x06,0x06,0x0c,0x08,0x00, // 94=^
|
||||
0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0, // 95=_
|
||||
0x00,0x00,0x01,0x03,0x06,0x04,0x00,0x00, // 96=`
|
||||
0x00,0x20,0x74,0x54,0x54,0x7c,0x78,0x00, // 97=a
|
||||
0x00,0x7f,0x7f,0x44,0x44,0x7c,0x38,0x00, // 98=b
|
||||
0x00,0x38,0x7c,0x44,0x44,0x6c,0x28,0x00, // 99=c
|
||||
0x00,0x38,0x7c,0x44,0x44,0x7f,0x7f,0x00, // 100=d
|
||||
0x00,0x38,0x7c,0x54,0x54,0x5c,0x58,0x00, // 101=e
|
||||
0x00,0x08,0x7e,0x7f,0x09,0x03,0x02,0x00, // 102=f
|
||||
0x00,0x98,0xbc,0xa4,0xa4,0xfc,0x7c,0x00, // 103=g
|
||||
0x00,0x7f,0x7f,0x04,0x04,0x7c,0x78,0x00, // 104=h
|
||||
0x00,0x00,0x00,0x7d,0x7d,0x00,0x00,0x00, // 105=i
|
||||
0x00,0x40,0xc0,0x80,0x80,0xfd,0x7d,0x00, // 106=j
|
||||
0x00,0x7f,0x7f,0x30,0x38,0x6c,0x44,0x00, // 107=k
|
||||
0x00,0x00,0x41,0x7f,0x7f,0x40,0x00,0x00, // 108=l
|
||||
0x00,0x7c,0x7c,0x18,0x30,0x18,0x7c,0x7c, // 109=m
|
||||
0x00,0x7c,0x7c,0x04,0x04,0x7c,0x78,0x00, // 110=n
|
||||
0x00,0x38,0x7c,0x44,0x44,0x7c,0x38,0x00, // 111=o
|
||||
0x00,0xfc,0xfc,0x24,0x24,0x3c,0x18,0x00, // 112=p
|
||||
0x00,0x18,0x3c,0x24,0x24,0xfc,0xfc,0x00, // 113=q
|
||||
0x00,0x7c,0x7c,0x04,0x04,0x0c,0x08,0x00, // 114=r
|
||||
0x00,0x48,0x5c,0x54,0x54,0x74,0x20,0x00, // 115=s
|
||||
0x04,0x04,0x3f,0x7f,0x44,0x64,0x20,0x00, // 116=t
|
||||
0x00,0x3c,0x7c,0x40,0x40,0x7c,0x3c,0x00, // 117=u
|
||||
0x00,0x1c,0x3c,0x60,0x60,0x3c,0x1c,0x00, // 118=v
|
||||
0x00,0x1c,0x7c,0x30,0x18,0x30,0x7c,0x1c, // 119=w
|
||||
0x00,0x44,0x6c,0x38,0x38,0x6c,0x44,0x00, // 120=x
|
||||
0x00,0x9c,0xbc,0xa0,0xa0,0xfc,0x7c,0x00, // 121=y
|
||||
0x00,0x44,0x64,0x74,0x5c,0x4c,0x44,0x00, // 122=z
|
||||
0x00,0x08,0x08,0x3e,0x77,0x41,0x41,0x00, // 123={
|
||||
0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00, // 124=|
|
||||
0x00,0x41,0x41,0x77,0x3e,0x08,0x08,0x00, // 125=}
|
||||
0x00,0x02,0x03,0x01,0x03,0x02,0x03,0x01, // 126=~
|
||||
0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55, // 127
|
||||
};
|
||||
|
||||
#endif // MICROPY_INCLUDED_STM32_FONT_PETME128_8X8_H
|
|
@ -287,14 +287,14 @@ STATIC void machine_i2c_obj_init_helper(machine_i2c_obj_t *self, size_t n_args,
|
|||
mp_hal_i2c_init(self, args[ARG_freq].u_int);
|
||||
}
|
||||
|
||||
STATIC mp_obj_t machine_i2c_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t machine_i2c_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
// check the id argument, if given
|
||||
if (n_args > 0) {
|
||||
if (args[0] != MP_OBJ_NEW_SMALL_INT(-1)) {
|
||||
#if defined(MICROPY_PY_MACHINE_I2C_MAKE_NEW)
|
||||
// dispatch to port-specific constructor
|
||||
extern mp_obj_t MICROPY_PY_MACHINE_I2C_MAKE_NEW(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args);
|
||||
return MICROPY_PY_MACHINE_I2C_MAKE_NEW(type, n_args, n_kw, args);
|
||||
extern mp_obj_t MICROPY_PY_MACHINE_I2C_MAKE_NEW(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *all_args, mp_map_t *kw_args);
|
||||
return MICROPY_PY_MACHINE_I2C_MAKE_NEW(type, n_args, args, kw_args);
|
||||
#else
|
||||
mp_raise_ValueError(translate("invalid I2C peripheral"));
|
||||
#endif
|
||||
|
@ -306,9 +306,7 @@ STATIC mp_obj_t machine_i2c_make_new(const mp_obj_type_t *type, size_t n_args, s
|
|||
// create new soft I2C object
|
||||
machine_i2c_obj_t *self = m_new_obj(machine_i2c_obj_t);
|
||||
self->base.type = &machine_i2c_type;
|
||||
mp_map_t kw_args;
|
||||
mp_map_init_fixed_table(&kw_args, n_kw, args + n_args);
|
||||
machine_i2c_obj_init_helper(self, n_args, args, &kw_args);
|
||||
machine_i2c_obj_init_helper(self, n_args, args, kw_args);
|
||||
return (mp_obj_t)self;
|
||||
}
|
||||
|
||||
|
@ -320,7 +318,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(machine_i2c_init_obj, 1, machine_i2c_obj_init);
|
|||
|
||||
STATIC mp_obj_t machine_i2c_scan(mp_obj_t self_in) {
|
||||
mp_obj_base_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol;
|
||||
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)mp_proto_get(self, QSTR_protocol_i2c);
|
||||
mp_obj_t list = mp_obj_new_list(0, NULL);
|
||||
// 7-bit addresses 0b0000xxx and 0b1111xxx are reserved
|
||||
for (int addr = 0x08; addr < 0x78; ++addr) {
|
||||
|
@ -335,7 +333,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(machine_i2c_scan_obj, machine_i2c_scan);
|
|||
|
||||
STATIC mp_obj_t machine_i2c_start(mp_obj_t self_in) {
|
||||
mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(self_in);
|
||||
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol;
|
||||
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)mp_proto_get(self, QSTR_protocol_i2c);
|
||||
if (i2c_p->start == NULL) {
|
||||
mp_raise_msg(&mp_type_OSError, translate("I2C operation not supported"));
|
||||
}
|
||||
|
@ -349,7 +347,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(machine_i2c_start_obj, machine_i2c_start);
|
|||
|
||||
STATIC mp_obj_t machine_i2c_stop(mp_obj_t self_in) {
|
||||
mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(self_in);
|
||||
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol;
|
||||
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)mp_proto_get(self, QSTR_protocol_i2c);
|
||||
if (i2c_p->stop == NULL) {
|
||||
mp_raise_msg(&mp_type_OSError, translate("I2C operation not supported"));
|
||||
}
|
||||
|
@ -363,7 +361,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(machine_i2c_stop_obj, machine_i2c_stop);
|
|||
|
||||
STATIC mp_obj_t machine_i2c_readinto(size_t n_args, const mp_obj_t *args) {
|
||||
mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]);
|
||||
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol;
|
||||
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)mp_proto_get(self, QSTR_protocol_i2c);
|
||||
if (i2c_p->read == NULL) {
|
||||
mp_raise_msg(&mp_type_OSError, translate("I2C operation not supported"));
|
||||
}
|
||||
|
@ -387,7 +385,7 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_i2c_readinto_obj, 2, 3, machine_i2c_
|
|||
|
||||
STATIC mp_obj_t machine_i2c_write(mp_obj_t self_in, mp_obj_t buf_in) {
|
||||
mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(self_in);
|
||||
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol;
|
||||
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)mp_proto_get(self, QSTR_protocol_i2c);
|
||||
if (i2c_p->write == NULL) {
|
||||
mp_raise_msg(&mp_type_OSError, translate("I2C operation not supported"));
|
||||
}
|
||||
|
@ -409,7 +407,7 @@ MP_DEFINE_CONST_FUN_OBJ_2(machine_i2c_write_obj, machine_i2c_write);
|
|||
|
||||
STATIC mp_obj_t machine_i2c_readfrom(size_t n_args, const mp_obj_t *args) {
|
||||
mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]);
|
||||
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol;
|
||||
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)mp_proto_get(self, QSTR_protocol_i2c);
|
||||
mp_int_t addr = mp_obj_get_int(args[1]);
|
||||
vstr_t vstr;
|
||||
vstr_init_len(&vstr, mp_obj_get_int(args[2]));
|
||||
|
@ -424,7 +422,7 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_i2c_readfrom_obj, 3, 4, machine_i2c_
|
|||
|
||||
STATIC mp_obj_t machine_i2c_readfrom_into(size_t n_args, const mp_obj_t *args) {
|
||||
mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]);
|
||||
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol;
|
||||
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)mp_proto_get(self, QSTR_protocol_i2c);
|
||||
mp_int_t addr = mp_obj_get_int(args[1]);
|
||||
mp_buffer_info_t bufinfo;
|
||||
mp_get_buffer_raise(args[2], &bufinfo, MP_BUFFER_WRITE);
|
||||
|
@ -439,7 +437,7 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_i2c_readfrom_into_obj, 3, 4, machine
|
|||
|
||||
STATIC mp_obj_t machine_i2c_writeto(size_t n_args, const mp_obj_t *args) {
|
||||
mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]);
|
||||
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol;
|
||||
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)mp_proto_get(self, QSTR_protocol_i2c);
|
||||
mp_int_t addr = mp_obj_get_int(args[1]);
|
||||
mp_buffer_info_t bufinfo;
|
||||
mp_get_buffer_raise(args[2], &bufinfo, MP_BUFFER_READ);
|
||||
|
@ -455,7 +453,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_i2c_writeto_obj, 3, 4, machin
|
|||
|
||||
STATIC int read_mem(mp_obj_t self_in, uint16_t addr, uint32_t memaddr, uint8_t addrsize, uint8_t *buf, size_t len) {
|
||||
mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(self_in);
|
||||
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol;
|
||||
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)mp_proto_get(self, QSTR_protocol_i2c);
|
||||
uint8_t memaddr_buf[4];
|
||||
size_t memaddr_len = 0;
|
||||
for (int16_t i = addrsize - 8; i >= 0; i -= 8) {
|
||||
|
@ -475,7 +473,7 @@ STATIC int read_mem(mp_obj_t self_in, uint16_t addr, uint32_t memaddr, uint8_t a
|
|||
|
||||
STATIC int write_mem(mp_obj_t self_in, uint16_t addr, uint32_t memaddr, uint8_t addrsize, const uint8_t *buf, size_t len) {
|
||||
mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(self_in);
|
||||
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol;
|
||||
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)mp_proto_get(self, QSTR_protocol_i2c);
|
||||
|
||||
// need some memory to create the buffer to send; try to use stack if possible
|
||||
uint8_t buf2_stack[MAX_MEMADDR_SIZE + BUF_STACK_SIZE];
|
||||
|
@ -623,6 +621,7 @@ int mp_machine_soft_i2c_write(mp_obj_base_t *self_in, const uint8_t *src, size_t
|
|||
}
|
||||
|
||||
STATIC const mp_machine_i2c_p_t mp_machine_soft_i2c_p = {
|
||||
MP_PROTO_IMPLEMENT(MP_QSTR_protocol_i2c)
|
||||
.start = (int(*)(mp_obj_base_t*))mp_hal_i2c_start,
|
||||
.stop = (int(*)(mp_obj_base_t*))mp_hal_i2c_stop,
|
||||
.read = mp_machine_soft_i2c_read,
|
||||
|
|
|
@ -27,10 +27,12 @@
|
|||
#define MICROPY_INCLUDED_EXTMOD_MACHINE_I2C_H
|
||||
|
||||
#include "py/obj.h"
|
||||
#include "py/proto.h"
|
||||
|
||||
// I2C protocol
|
||||
// the first 4 methods can be NULL, meaning operation is not supported
|
||||
typedef struct _mp_machine_i2c_p_t {
|
||||
MP_PROTOCOL_HEAD
|
||||
int (*start)(mp_obj_base_t *obj);
|
||||
int (*stop)(mp_obj_base_t *obj);
|
||||
int (*read)(mp_obj_base_t *obj, uint8_t *dest, size_t len, bool nack);
|
||||
|
|
|
@ -45,11 +45,11 @@ STATIC const mp_pinbase_t pinbase_singleton = {
|
|||
.base = { &machine_pinbase_type },
|
||||
};
|
||||
|
||||
STATIC mp_obj_t pinbase_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t pinbase_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
(void)type;
|
||||
(void)n_args;
|
||||
(void)n_kw;
|
||||
(void)args;
|
||||
(void)kw_args;
|
||||
return MP_OBJ_FROM_PTR(&pinbase_singleton);
|
||||
}
|
||||
|
||||
|
@ -74,6 +74,7 @@ mp_uint_t pinbase_ioctl(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *err
|
|||
}
|
||||
|
||||
STATIC const mp_pin_p_t pinbase_pin_p = {
|
||||
MP_PROTO_IMPLEMENT(MP_QSTR_protocol_pin)
|
||||
.ioctl = pinbase_ioctl,
|
||||
};
|
||||
|
||||
|
|
|
@ -42,17 +42,12 @@ typedef struct _machine_signal_t {
|
|||
bool invert;
|
||||
} machine_signal_t;
|
||||
|
||||
STATIC mp_obj_t signal_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t signal_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
mp_obj_t pin = args[0];
|
||||
bool invert = false;
|
||||
|
||||
#if defined(MICROPY_PY_MACHINE_PIN_MAKE_NEW)
|
||||
mp_pin_p_t *pin_p = NULL;
|
||||
|
||||
if (MP_OBJ_IS_OBJ(pin)) {
|
||||
mp_obj_base_t *pin_base = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]);
|
||||
pin_p = (mp_pin_p_t*)pin_base->type->protocol;
|
||||
}
|
||||
mp_pin_p_t *pin_p = (mp_pin_t*)mp_proto_get(QSTR_pin_protocol, pin);
|
||||
|
||||
if (pin_p == NULL) {
|
||||
// If first argument isn't a Pin-like object, we filter out "invert"
|
||||
|
@ -96,9 +91,9 @@ STATIC mp_obj_t signal_make_new(const mp_obj_type_t *type, size_t n_args, size_t
|
|||
// Otherwise there should be 1 or 2 args
|
||||
{
|
||||
if (n_args == 1) {
|
||||
if (n_kw == 0) {
|
||||
} else if (n_kw == 1 && args[1] == MP_OBJ_NEW_QSTR(MP_QSTR_invert)) {
|
||||
invert = mp_obj_is_true(args[2]);
|
||||
if (kw_args == NULL || kw_args->used == 0) {
|
||||
} else if (kw_args->used == 1 && kw_args->table[0].key == MP_OBJ_NEW_QSTR(MP_QSTR_invert)) {
|
||||
invert = mp_obj_is_true(kw_args->table[0].value);
|
||||
} else {
|
||||
goto error;
|
||||
}
|
||||
|
@ -133,7 +128,7 @@ STATIC mp_uint_t signal_ioctl(mp_obj_t self_in, mp_uint_t request, uintptr_t arg
|
|||
|
||||
// fast method for getting/setting signal value
|
||||
STATIC mp_obj_t signal_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
|
||||
mp_arg_check_num(n_args, n_kw, 0, 1, false);
|
||||
mp_arg_check_num_kw_array(n_args, n_kw, 0, 1, false);
|
||||
if (n_args == 0) {
|
||||
// get pin
|
||||
return MP_OBJ_NEW_SMALL_INT(mp_virtual_pin_read(self_in));
|
||||
|
@ -170,6 +165,7 @@ STATIC const mp_rom_map_elem_t signal_locals_dict_table[] = {
|
|||
STATIC MP_DEFINE_CONST_DICT(signal_locals_dict, signal_locals_dict_table);
|
||||
|
||||
STATIC const mp_pin_p_t signal_pin_p = {
|
||||
MP_PROTO_IMPLEMENT(MP_QSTR_protocol_pin)
|
||||
.ioctl = signal_ioctl,
|
||||
};
|
||||
|
||||
|
|
|
@ -43,16 +43,16 @@
|
|||
/******************************************************************************/
|
||||
// MicroPython bindings for generic machine.SPI
|
||||
|
||||
STATIC mp_obj_t mp_machine_soft_spi_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args);
|
||||
STATIC mp_obj_t mp_machine_soft_spi_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args);
|
||||
|
||||
mp_obj_t mp_machine_spi_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
|
||||
mp_obj_t mp_machine_spi_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
// check the id argument, if given
|
||||
if (n_args > 0) {
|
||||
if (args[0] != MP_OBJ_NEW_SMALL_INT(-1)) {
|
||||
#if defined(MICROPY_PY_MACHINE_SPI_MAKE_NEW)
|
||||
// dispatch to port-specific constructor
|
||||
extern mp_obj_t MICROPY_PY_MACHINE_SPI_MAKE_NEW(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args);
|
||||
return MICROPY_PY_MACHINE_SPI_MAKE_NEW(type, n_args, n_kw, args);
|
||||
extern mp_obj_t MICROPY_PY_MACHINE_SPI_MAKE_NEW(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args);
|
||||
return MICROPY_PY_MACHINE_SPI_MAKE_NEW(type, n_args, args, kw_args);
|
||||
#else
|
||||
mp_raise_ValueError(translate("invalid SPI peripheral"));
|
||||
#endif
|
||||
|
@ -62,12 +62,12 @@ mp_obj_t mp_machine_spi_make_new(const mp_obj_type_t *type, size_t n_args, size_
|
|||
}
|
||||
|
||||
// software SPI
|
||||
return mp_machine_soft_spi_make_new(type, n_args, n_kw, args);
|
||||
return mp_machine_soft_spi_make_new(type, n_args, args, kw_args);
|
||||
}
|
||||
|
||||
STATIC mp_obj_t machine_spi_init(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
mp_obj_base_t *s = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]);
|
||||
mp_machine_spi_p_t *spi_p = (mp_machine_spi_p_t*)s->type->protocol;
|
||||
mp_machine_spi_p_t *spi_p = (mp_machine_spi_p_t*)mp_proto_get(QSTR_protocol_spi, s);
|
||||
spi_p->init(s, n_args - 1, args + 1, kw_args);
|
||||
return mp_const_none;
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(machine_spi_init_obj, 1, machine_spi_init);
|
|||
|
||||
STATIC mp_obj_t machine_spi_deinit(mp_obj_t self) {
|
||||
mp_obj_base_t *s = (mp_obj_base_t*)MP_OBJ_TO_PTR(self);
|
||||
mp_machine_spi_p_t *spi_p = (mp_machine_spi_p_t*)s->type->protocol;
|
||||
mp_machine_spi_p_t *spi_p = (mp_machine_spi_p_t*)mp_proto_get(QSTR_protocol_spi, s);
|
||||
if (spi_p->deinit != NULL) {
|
||||
spi_p->deinit(s);
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(machine_spi_deinit_obj, machine_spi_deinit);
|
|||
|
||||
STATIC void mp_machine_spi_transfer(mp_obj_t self, size_t len, const void *src, void *dest) {
|
||||
mp_obj_base_t *s = (mp_obj_base_t*)MP_OBJ_TO_PTR(self);
|
||||
mp_machine_spi_p_t *spi_p = (mp_machine_spi_p_t*)s->type->protocol;
|
||||
mp_machine_spi_p_t *spi_p = (mp_machine_spi_p_t*)mp_proto_get(QSTR_protocol_spi, s);
|
||||
spi_p->transfer(s, len, src, dest);
|
||||
}
|
||||
|
||||
|
@ -180,7 +180,7 @@ STATIC void mp_machine_soft_spi_print(const mp_print_t *print, mp_obj_t self_in,
|
|||
mp_hal_pin_name(self->spi.sck), mp_hal_pin_name(self->spi.mosi), mp_hal_pin_name(self->spi.miso));
|
||||
}
|
||||
|
||||
STATIC mp_obj_t mp_machine_soft_spi_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
|
||||
STATIC mp_obj_t mp_machine_soft_spi_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *all_args, mp_map_t *kw_args) {
|
||||
enum { ARG_baudrate, ARG_polarity, ARG_phase, ARG_bits, ARG_firstbit, ARG_sck, ARG_mosi, ARG_miso };
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
{ MP_QSTR_baudrate, MP_ARG_INT, {.u_int = 500000} },
|
||||
|
@ -193,7 +193,7 @@ STATIC mp_obj_t mp_machine_soft_spi_make_new(const mp_obj_type_t *type, size_t n
|
|||
{ MP_QSTR_miso, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
|
||||
};
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
mp_arg_parse_all(n_args, all_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
|
||||
// create new object
|
||||
mp_machine_soft_spi_obj_t *self = m_new_obj(mp_machine_soft_spi_obj_t);
|
||||
|
@ -268,6 +268,7 @@ STATIC void mp_machine_soft_spi_transfer(mp_obj_base_t *self_in, size_t len, con
|
|||
}
|
||||
|
||||
const mp_machine_spi_p_t mp_machine_soft_spi_p = {
|
||||
MP_PROTO_IMPLEMENT(MP_QSTR_protocol_spi)
|
||||
.init = mp_machine_soft_spi_init,
|
||||
.deinit = NULL,
|
||||
.transfer = mp_machine_soft_spi_transfer,
|
||||
|
|
|
@ -27,11 +27,13 @@
|
|||
#define MICROPY_INCLUDED_EXTMOD_MACHINE_SPI_H
|
||||
|
||||
#include "py/obj.h"
|
||||
#include "py/proto.h"
|
||||
#include "py/mphal.h"
|
||||
#include "drivers/bus/spi.h"
|
||||
|
||||
// SPI protocol
|
||||
typedef struct _mp_machine_spi_p_t {
|
||||
MP_PROTOCOL_HEAD
|
||||
void (*init)(mp_obj_base_t *obj, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args);
|
||||
void (*deinit)(mp_obj_base_t *obj); // can be NULL
|
||||
void (*transfer)(mp_obj_base_t *obj, size_t len, const uint8_t *src, uint8_t *dest);
|
||||
|
|
|
@ -247,7 +247,7 @@ STATIC mp_obj_t btree_iternext(mp_obj_t self_in) {
|
|||
}
|
||||
|
||||
STATIC mp_obj_t btree_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
|
||||
mp_obj_btree_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
mp_obj_btree_t *self = mp_instance_cast_to_native_base(self_in, &btree_type);
|
||||
if (value == MP_OBJ_NULL) {
|
||||
// delete
|
||||
DBT key;
|
||||
|
|
|
@ -28,10 +28,12 @@
|
|||
#include <string.h>
|
||||
|
||||
#include "py/runtime.h"
|
||||
#include "py/objtype.h"
|
||||
#include "py/proto.h"
|
||||
|
||||
#if MICROPY_PY_FRAMEBUF
|
||||
|
||||
#include "ports/stm32/font_petme128_8x8.h"
|
||||
#include "font_petme128_8x8.h"
|
||||
|
||||
typedef struct _mp_obj_framebuf_t {
|
||||
mp_obj_base_t base;
|
||||
|
@ -46,6 +48,7 @@ typedef uint32_t (*getpixel_t)(const mp_obj_framebuf_t*, int, int);
|
|||
typedef void (*fill_rect_t)(const mp_obj_framebuf_t *, int, int, int, int, uint32_t);
|
||||
|
||||
typedef struct _mp_framebuf_p_t {
|
||||
MP_PROTOCOL_HEAD
|
||||
setpixel_t setpixel;
|
||||
getpixel_t getpixel;
|
||||
fill_rect_t fill_rect;
|
||||
|
@ -227,13 +230,13 @@ STATIC void gs8_fill_rect(const mp_obj_framebuf_t *fb, int x, int y, int w, int
|
|||
}
|
||||
|
||||
STATIC mp_framebuf_p_t formats[] = {
|
||||
[FRAMEBUF_MVLSB] = {mvlsb_setpixel, mvlsb_getpixel, mvlsb_fill_rect},
|
||||
[FRAMEBUF_RGB565] = {rgb565_setpixel, rgb565_getpixel, rgb565_fill_rect},
|
||||
[FRAMEBUF_GS2_HMSB] = {gs2_hmsb_setpixel, gs2_hmsb_getpixel, gs2_hmsb_fill_rect},
|
||||
[FRAMEBUF_GS4_HMSB] = {gs4_hmsb_setpixel, gs4_hmsb_getpixel, gs4_hmsb_fill_rect},
|
||||
[FRAMEBUF_GS8] = {gs8_setpixel, gs8_getpixel, gs8_fill_rect},
|
||||
[FRAMEBUF_MHLSB] = {mono_horiz_setpixel, mono_horiz_getpixel, mono_horiz_fill_rect},
|
||||
[FRAMEBUF_MHMSB] = {mono_horiz_setpixel, mono_horiz_getpixel, mono_horiz_fill_rect},
|
||||
[FRAMEBUF_MVLSB] = {MP_PROTO_IMPLEMENT(MP_QSTR_protocol_framebuf) mvlsb_setpixel, mvlsb_getpixel, mvlsb_fill_rect},
|
||||
[FRAMEBUF_RGB565] = {MP_PROTO_IMPLEMENT(MP_QSTR_protocol_framebuf) rgb565_setpixel, rgb565_getpixel, rgb565_fill_rect},
|
||||
[FRAMEBUF_GS2_HMSB] = {MP_PROTO_IMPLEMENT(MP_QSTR_protocol_framebuf) gs2_hmsb_setpixel, gs2_hmsb_getpixel, gs2_hmsb_fill_rect},
|
||||
[FRAMEBUF_GS4_HMSB] = {MP_PROTO_IMPLEMENT(MP_QSTR_protocol_framebuf) gs4_hmsb_setpixel, gs4_hmsb_getpixel, gs4_hmsb_fill_rect},
|
||||
[FRAMEBUF_GS8] = {MP_PROTO_IMPLEMENT(MP_QSTR_protocol_framebuf) gs8_setpixel, gs8_getpixel, gs8_fill_rect},
|
||||
[FRAMEBUF_MHLSB] = {MP_PROTO_IMPLEMENT(MP_QSTR_protocol_framebuf) mono_horiz_setpixel, mono_horiz_getpixel, mono_horiz_fill_rect},
|
||||
[FRAMEBUF_MHMSB] = {MP_PROTO_IMPLEMENT(MP_QSTR_protocol_framebuf) mono_horiz_setpixel, mono_horiz_getpixel, mono_horiz_fill_rect},
|
||||
};
|
||||
|
||||
static inline void setpixel(const mp_obj_framebuf_t *fb, int x, int y, uint32_t col) {
|
||||
|
@ -259,8 +262,8 @@ STATIC void fill_rect(const mp_obj_framebuf_t *fb, int x, int y, int w, int h, u
|
|||
formats[fb->format].fill_rect(fb, x, y, xend - x, yend - y, col);
|
||||
}
|
||||
|
||||
STATIC mp_obj_t framebuf_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
|
||||
mp_arg_check_num(n_args, n_kw, 4, 5, false);
|
||||
STATIC mp_obj_t framebuf_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
mp_arg_check_num(n_args, kw_args, 4, 5, false);
|
||||
|
||||
mp_obj_framebuf_t *o = m_new_obj(mp_obj_framebuf_t);
|
||||
o->base.type = type;
|
||||
|
@ -302,9 +305,18 @@ STATIC mp_obj_t framebuf_make_new(const mp_obj_type_t *type, size_t n_args, size
|
|||
return MP_OBJ_FROM_PTR(o);
|
||||
}
|
||||
|
||||
STATIC const mp_obj_type_t mp_type_framebuf;
|
||||
|
||||
// Helper to ensure we have the native super class instead of a subclass.
|
||||
static mp_obj_framebuf_t* native_framebuf(mp_obj_t framebuf_obj) {
|
||||
mp_obj_t native_framebuf = mp_instance_cast_to_native_base(framebuf_obj, &mp_type_framebuf);
|
||||
mp_obj_assert_native_inited(native_framebuf);
|
||||
return MP_OBJ_TO_PTR(native_framebuf);
|
||||
}
|
||||
|
||||
STATIC mp_int_t framebuf_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags) {
|
||||
(void)flags;
|
||||
mp_obj_framebuf_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
mp_obj_framebuf_t *self = native_framebuf(self_in);
|
||||
bufinfo->buf = self->buf;
|
||||
bufinfo->len = self->stride * self->height * (self->format == FRAMEBUF_RGB565 ? 2 : 1);
|
||||
bufinfo->typecode = 'B'; // view framebuf as bytes
|
||||
|
@ -312,7 +324,7 @@ STATIC mp_int_t framebuf_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo,
|
|||
}
|
||||
|
||||
STATIC mp_obj_t framebuf_fill(mp_obj_t self_in, mp_obj_t col_in) {
|
||||
mp_obj_framebuf_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
mp_obj_framebuf_t *self = native_framebuf(self_in);
|
||||
mp_int_t col = mp_obj_get_int(col_in);
|
||||
formats[self->format].fill_rect(self, 0, 0, self->width, self->height, col);
|
||||
return mp_const_none;
|
||||
|
@ -322,7 +334,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(framebuf_fill_obj, framebuf_fill);
|
|||
STATIC mp_obj_t framebuf_fill_rect(size_t n_args, const mp_obj_t *args) {
|
||||
(void)n_args;
|
||||
|
||||
mp_obj_framebuf_t *self = MP_OBJ_TO_PTR(args[0]);
|
||||
mp_obj_framebuf_t *self = native_framebuf(args[0]);
|
||||
mp_int_t x = mp_obj_get_int(args[1]);
|
||||
mp_int_t y = mp_obj_get_int(args[2]);
|
||||
mp_int_t width = mp_obj_get_int(args[3]);
|
||||
|
@ -336,7 +348,7 @@ STATIC mp_obj_t framebuf_fill_rect(size_t n_args, const mp_obj_t *args) {
|
|||
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(framebuf_fill_rect_obj, 6, 6, framebuf_fill_rect);
|
||||
|
||||
STATIC mp_obj_t framebuf_pixel(size_t n_args, const mp_obj_t *args) {
|
||||
mp_obj_framebuf_t *self = MP_OBJ_TO_PTR(args[0]);
|
||||
mp_obj_framebuf_t *self = native_framebuf(args[0]);
|
||||
mp_int_t x = mp_obj_get_int(args[1]);
|
||||
mp_int_t y = mp_obj_get_int(args[2]);
|
||||
if (0 <= x && x < self->width && 0 <= y && y < self->height) {
|
||||
|
@ -355,7 +367,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(framebuf_pixel_obj, 3, 4, framebuf_pi
|
|||
STATIC mp_obj_t framebuf_hline(size_t n_args, const mp_obj_t *args) {
|
||||
(void)n_args;
|
||||
|
||||
mp_obj_framebuf_t *self = MP_OBJ_TO_PTR(args[0]);
|
||||
mp_obj_framebuf_t *self = native_framebuf(args[0]);
|
||||
mp_int_t x = mp_obj_get_int(args[1]);
|
||||
mp_int_t y = mp_obj_get_int(args[2]);
|
||||
mp_int_t w = mp_obj_get_int(args[3]);
|
||||
|
@ -370,7 +382,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(framebuf_hline_obj, 5, 5, framebuf_hl
|
|||
STATIC mp_obj_t framebuf_vline(size_t n_args, const mp_obj_t *args) {
|
||||
(void)n_args;
|
||||
|
||||
mp_obj_framebuf_t *self = MP_OBJ_TO_PTR(args[0]);
|
||||
mp_obj_framebuf_t *self = native_framebuf(args[0]);
|
||||
mp_int_t x = mp_obj_get_int(args[1]);
|
||||
mp_int_t y = mp_obj_get_int(args[2]);
|
||||
mp_int_t h = mp_obj_get_int(args[3]);
|
||||
|
@ -385,7 +397,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(framebuf_vline_obj, 5, 5, framebuf_vl
|
|||
STATIC mp_obj_t framebuf_rect(size_t n_args, const mp_obj_t *args) {
|
||||
(void)n_args;
|
||||
|
||||
mp_obj_framebuf_t *self = MP_OBJ_TO_PTR(args[0]);
|
||||
mp_obj_framebuf_t *self = native_framebuf(args[0]);
|
||||
mp_int_t x = mp_obj_get_int(args[1]);
|
||||
mp_int_t y = mp_obj_get_int(args[2]);
|
||||
mp_int_t w = mp_obj_get_int(args[3]);
|
||||
|
@ -404,7 +416,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(framebuf_rect_obj, 6, 6, framebuf_rec
|
|||
STATIC mp_obj_t framebuf_line(size_t n_args, const mp_obj_t *args) {
|
||||
(void)n_args;
|
||||
|
||||
mp_obj_framebuf_t *self = MP_OBJ_TO_PTR(args[0]);
|
||||
mp_obj_framebuf_t *self = native_framebuf(args[0]);
|
||||
mp_int_t x1 = mp_obj_get_int(args[1]);
|
||||
mp_int_t y1 = mp_obj_get_int(args[2]);
|
||||
mp_int_t x2 = mp_obj_get_int(args[3]);
|
||||
|
@ -468,8 +480,8 @@ STATIC mp_obj_t framebuf_line(size_t n_args, const mp_obj_t *args) {
|
|||
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(framebuf_line_obj, 6, 6, framebuf_line);
|
||||
|
||||
STATIC mp_obj_t framebuf_blit(size_t n_args, const mp_obj_t *args) {
|
||||
mp_obj_framebuf_t *self = MP_OBJ_TO_PTR(args[0]);
|
||||
mp_obj_framebuf_t *source = MP_OBJ_TO_PTR(args[1]);
|
||||
mp_obj_framebuf_t *self = native_framebuf(args[0]);
|
||||
mp_obj_framebuf_t *source = native_framebuf(args[1]);
|
||||
mp_int_t x = mp_obj_get_int(args[2]);
|
||||
mp_int_t y = mp_obj_get_int(args[3]);
|
||||
mp_int_t key = -1;
|
||||
|
@ -511,7 +523,7 @@ STATIC mp_obj_t framebuf_blit(size_t n_args, const mp_obj_t *args) {
|
|||
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(framebuf_blit_obj, 4, 5, framebuf_blit);
|
||||
|
||||
STATIC mp_obj_t framebuf_scroll(mp_obj_t self_in, mp_obj_t xstep_in, mp_obj_t ystep_in) {
|
||||
mp_obj_framebuf_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
mp_obj_framebuf_t *self = native_framebuf(self_in);
|
||||
mp_int_t xstep = mp_obj_get_int(xstep_in);
|
||||
mp_int_t ystep = mp_obj_get_int(ystep_in);
|
||||
int sx, y, xend, yend, dx, dy;
|
||||
|
@ -544,7 +556,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_3(framebuf_scroll_obj, framebuf_scroll);
|
|||
|
||||
STATIC mp_obj_t framebuf_text(size_t n_args, const mp_obj_t *args) {
|
||||
// extract arguments
|
||||
mp_obj_framebuf_t *self = MP_OBJ_TO_PTR(args[0]);
|
||||
mp_obj_framebuf_t *self = native_framebuf(args[0]);
|
||||
const char *str = mp_obj_str_get_str(args[1]);
|
||||
mp_int_t x0 = mp_obj_get_int(args[2]);
|
||||
mp_int_t y0 = mp_obj_get_int(args[3]);
|
||||
|
|
|
@ -1261,6 +1261,7 @@ STATIC const mp_rom_map_elem_t lwip_socket_locals_dict_table[] = {
|
|||
STATIC MP_DEFINE_CONST_DICT(lwip_socket_locals_dict, lwip_socket_locals_dict_table);
|
||||
|
||||
STATIC const mp_stream_p_t lwip_socket_stream_p = {
|
||||
MP_PROTO_IMPLEMENT(MP_QSTR_protocol_stream)
|
||||
.read = lwip_socket_read,
|
||||
.write = lwip_socket_write,
|
||||
.ioctl = lwip_socket_ioctl,
|
||||
|
|
|
@ -122,8 +122,8 @@ STATIC NORETURN void syntax_error(void) {
|
|||
mp_raise_TypeError(translate("syntax error in uctypes descriptor"));
|
||||
}
|
||||
|
||||
STATIC mp_obj_t uctypes_struct_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
|
||||
mp_arg_check_num(n_args, n_kw, 2, 3, false);
|
||||
STATIC mp_obj_t uctypes_struct_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
mp_arg_check_num(n_args, kw_args, 2, 3, false);
|
||||
mp_obj_uctypes_struct_t *o = m_new_obj(mp_obj_uctypes_struct_t);
|
||||
o->base.type = type;
|
||||
o->addr = (void*)(uintptr_t)mp_obj_int_get_truncated(args[0]);
|
||||
|
@ -518,8 +518,8 @@ STATIC void uctypes_struct_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
|
|||
}
|
||||
}
|
||||
|
||||
STATIC mp_obj_t uctypes_struct_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value) {
|
||||
mp_obj_uctypes_struct_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
STATIC mp_obj_t uctypes_struct_subscr(mp_obj_t base_in, mp_obj_t index_in, mp_obj_t value) {
|
||||
mp_obj_uctypes_struct_t *self = mp_instance_cast_to_native_base(base_in, &uctypes_struct_type);
|
||||
|
||||
if (value == MP_OBJ_NULL) {
|
||||
// delete
|
||||
|
|
|
@ -66,8 +66,8 @@ STATIC mp_obj_t uhashlib_sha256_update(mp_obj_t self_in, mp_obj_t arg);
|
|||
|
||||
#if MICROPY_SSL_MBEDTLS
|
||||
|
||||
STATIC mp_obj_t uhashlib_sha256_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
|
||||
mp_arg_check_num(n_args, n_kw, 0, 1, false);
|
||||
STATIC mp_obj_t uhashlib_sha256_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
mp_arg_check_num(n_args, kw_args, 0, 1, false);
|
||||
mp_obj_hash_t *o = m_new_obj_var(mp_obj_hash_t, char, sizeof(mbedtls_sha256_context));
|
||||
o->base.type = type;
|
||||
mbedtls_sha256_init((mbedtls_sha256_context*)&o->state);
|
||||
|
@ -104,8 +104,8 @@ static void check_not_unicode(const mp_obj_t arg) {
|
|||
#endif
|
||||
}
|
||||
|
||||
STATIC mp_obj_t uhashlib_sha256_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
|
||||
mp_arg_check_num(n_args, n_kw, 0, 1, false);
|
||||
STATIC mp_obj_t uhashlib_sha256_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
mp_arg_check_num(n_args, kw_args, 0, 1, false);
|
||||
mp_obj_hash_t *o = m_new_obj_var(mp_obj_hash_t, char, sizeof(CRYAL_SHA256_CTX));
|
||||
o->base.type = type;
|
||||
sha256_init((CRYAL_SHA256_CTX*)o->state);
|
||||
|
@ -155,8 +155,8 @@ STATIC const mp_obj_type_t uhashlib_sha256_type = {
|
|||
STATIC mp_obj_t uhashlib_sha1_update(mp_obj_t self_in, mp_obj_t arg);
|
||||
|
||||
#if MICROPY_SSL_AXTLS
|
||||
STATIC mp_obj_t uhashlib_sha1_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
|
||||
mp_arg_check_num(n_args, n_kw, 0, 1, false);
|
||||
STATIC mp_obj_t uhashlib_sha1_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
mp_arg_check_num(n_args, kw_args, 0, 1, false);
|
||||
mp_obj_hash_t *o = m_new_obj_var(mp_obj_hash_t, char, sizeof(SHA1_CTX));
|
||||
o->base.type = type;
|
||||
SHA1_Init((SHA1_CTX*)o->state);
|
||||
|
|
|
@ -53,6 +53,10 @@ STATIC mp_obj_t mod_ujson_dumps(mp_obj_t obj) {
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_ujson_dumps_obj, mod_ujson_dumps);
|
||||
|
||||
#define JSON_DEBUG(...) (void)0
|
||||
// #define JSON_DEBUG(...) mp_printf(&mp_plat_print __VA_OPT__(,) __VA_ARGS__)
|
||||
|
||||
|
||||
// The function below implements a simple non-recursive JSON parser.
|
||||
//
|
||||
// The JSON specification is at http://www.ietf.org/rfc/rfc4627.txt
|
||||
|
@ -80,6 +84,7 @@ typedef struct _ujson_stream_t {
|
|||
|
||||
STATIC byte ujson_stream_next(ujson_stream_t *s) {
|
||||
mp_uint_t ret = s->read(s->stream_obj, &s->cur, 1, &s->errcode);
|
||||
JSON_DEBUG(" usjon_stream_next err:%2d cur: %c \n", s->errcode, s->cur);
|
||||
if (s->errcode != 0) {
|
||||
mp_raise_OSError(s->errcode);
|
||||
}
|
||||
|
@ -89,9 +94,10 @@ STATIC byte ujson_stream_next(ujson_stream_t *s) {
|
|||
return s->cur;
|
||||
}
|
||||
|
||||
STATIC mp_obj_t mod_ujson_load(mp_obj_t stream_obj) {
|
||||
STATIC mp_obj_t _mod_ujson_load(mp_obj_t stream_obj, bool return_first_json) {
|
||||
const mp_stream_p_t *stream_p = mp_get_stream_raise(stream_obj, MP_STREAM_OP_READ);
|
||||
ujson_stream_t s = {stream_obj, stream_p->read, 0, 0};
|
||||
JSON_DEBUG("got JSON stream\n");
|
||||
vstr_t vstr;
|
||||
vstr_init(&vstr, 8);
|
||||
mp_obj_list_t stack; // we use a list as a simple stack for nested JSON
|
||||
|
@ -262,13 +268,18 @@ STATIC mp_obj_t mod_ujson_load(mp_obj_t stream_obj) {
|
|||
}
|
||||
}
|
||||
success:
|
||||
// eat trailing whitespace
|
||||
while (unichar_isspace(S_CUR(s))) {
|
||||
S_NEXT(s);
|
||||
}
|
||||
if (!S_END(s)) {
|
||||
// unexpected chars
|
||||
goto fail;
|
||||
// It is legal for a stream to have contents after JSON.
|
||||
// E.g., A UART is not closed after receiving an object; in load() we will
|
||||
// return the first complete JSON object, while in loads() we will retain
|
||||
// strict adherence to the buffer's complete semantic.
|
||||
if (!return_first_json) {
|
||||
while (unichar_isspace(S_CUR(s))) {
|
||||
S_NEXT(s);
|
||||
}
|
||||
if (!S_END(s)) {
|
||||
// unexpected chars
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
if (stack_top == MP_OBJ_NULL || stack.len != 0) {
|
||||
// not exactly 1 object
|
||||
|
@ -280,6 +291,10 @@ STATIC mp_obj_t mod_ujson_load(mp_obj_t stream_obj) {
|
|||
fail:
|
||||
mp_raise_ValueError(translate("syntax error in JSON"));
|
||||
}
|
||||
|
||||
STATIC mp_obj_t mod_ujson_load(mp_obj_t stream_obj) {
|
||||
return _mod_ujson_load(stream_obj, true);
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_ujson_load_obj, mod_ujson_load);
|
||||
|
||||
STATIC mp_obj_t mod_ujson_loads(mp_obj_t obj) {
|
||||
|
@ -287,12 +302,16 @@ STATIC mp_obj_t mod_ujson_loads(mp_obj_t obj) {
|
|||
const char *buf = mp_obj_str_get_data(obj, &len);
|
||||
vstr_t vstr = {len, len, (char*)buf, true};
|
||||
mp_obj_stringio_t sio = {{&mp_type_stringio}, &vstr, 0, MP_OBJ_NULL};
|
||||
return mod_ujson_load(MP_OBJ_FROM_PTR(&sio));
|
||||
return _mod_ujson_load(MP_OBJ_FROM_PTR(&sio), false);
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_ujson_loads_obj, mod_ujson_loads);
|
||||
|
||||
STATIC const mp_rom_map_elem_t mp_module_ujson_globals_table[] = {
|
||||
#if CIRCUITPY
|
||||
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_json) },
|
||||
#else
|
||||
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_ujson) },
|
||||
#endif
|
||||
{ MP_ROM_QSTR(MP_QSTR_dump), MP_ROM_PTR(&mod_ujson_dump_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_dumps), MP_ROM_PTR(&mod_ujson_dumps_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_load), MP_ROM_PTR(&mod_ujson_load_obj) },
|
||||
|
|
240
extmod/modure.c
240
extmod/modure.c
|
@ -77,8 +77,83 @@ STATIC mp_obj_t match_group(mp_obj_t self_in, mp_obj_t no_in) {
|
|||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_2(match_group_obj, match_group);
|
||||
|
||||
#if MICROPY_PY_URE_MATCH_GROUPS
|
||||
|
||||
STATIC mp_obj_t match_groups(mp_obj_t self_in) {
|
||||
mp_obj_match_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
if (self->num_matches <= 1) {
|
||||
return mp_const_empty_tuple;
|
||||
}
|
||||
mp_obj_tuple_t *groups = MP_OBJ_TO_PTR(mp_obj_new_tuple(self->num_matches - 1, NULL));
|
||||
for (int i = 1; i < self->num_matches; ++i) {
|
||||
groups->items[i - 1] = match_group(self_in, MP_OBJ_NEW_SMALL_INT(i));
|
||||
}
|
||||
return MP_OBJ_FROM_PTR(groups);
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(match_groups_obj, match_groups);
|
||||
|
||||
#endif
|
||||
|
||||
#if MICROPY_PY_URE_MATCH_SPAN_START_END
|
||||
|
||||
STATIC void match_span_helper(size_t n_args, const mp_obj_t *args, mp_obj_t span[2]) {
|
||||
mp_obj_match_t *self = MP_OBJ_TO_PTR(args[0]);
|
||||
|
||||
mp_int_t no = 0;
|
||||
if (n_args == 2) {
|
||||
no = mp_obj_get_int(args[1]);
|
||||
if (no < 0 || no >= self->num_matches) {
|
||||
nlr_raise(mp_obj_new_exception_arg1(&mp_type_IndexError, args[1]));
|
||||
}
|
||||
}
|
||||
|
||||
mp_int_t s = -1;
|
||||
mp_int_t e = -1;
|
||||
const char *start = self->caps[no * 2];
|
||||
if (start != NULL) {
|
||||
// have a match for this group
|
||||
const char *begin = mp_obj_str_get_str(self->str);
|
||||
s = start - begin;
|
||||
e = self->caps[no * 2 + 1] - begin;
|
||||
}
|
||||
|
||||
span[0] = mp_obj_new_int(s);
|
||||
span[1] = mp_obj_new_int(e);
|
||||
}
|
||||
|
||||
STATIC mp_obj_t match_span(size_t n_args, const mp_obj_t *args) {
|
||||
mp_obj_t span[2];
|
||||
match_span_helper(n_args, args, span);
|
||||
return mp_obj_new_tuple(2, span);
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(match_span_obj, 1, 2, match_span);
|
||||
|
||||
STATIC mp_obj_t match_start(size_t n_args, const mp_obj_t *args) {
|
||||
mp_obj_t span[2];
|
||||
match_span_helper(n_args, args, span);
|
||||
return span[0];
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(match_start_obj, 1, 2, match_start);
|
||||
|
||||
STATIC mp_obj_t match_end(size_t n_args, const mp_obj_t *args) {
|
||||
mp_obj_t span[2];
|
||||
match_span_helper(n_args, args, span);
|
||||
return span[1];
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(match_end_obj, 1, 2, match_end);
|
||||
|
||||
#endif
|
||||
|
||||
STATIC const mp_rom_map_elem_t match_locals_dict_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR_group), MP_ROM_PTR(&match_group_obj) },
|
||||
#if MICROPY_PY_URE_MATCH_GROUPS
|
||||
{ MP_ROM_QSTR(MP_QSTR_groups), MP_ROM_PTR(&match_groups_obj) },
|
||||
#endif
|
||||
#if MICROPY_PY_URE_MATCH_SPAN_START_END
|
||||
{ MP_ROM_QSTR(MP_QSTR_span), MP_ROM_PTR(&match_span_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_start), MP_ROM_PTR(&match_start_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_end), MP_ROM_PTR(&match_end_obj) },
|
||||
#endif
|
||||
};
|
||||
|
||||
STATIC MP_DEFINE_CONST_DICT(match_locals_dict, match_locals_dict_table);
|
||||
|
@ -103,6 +178,35 @@ STATIC mp_obj_t ure_exec(bool is_anchored, uint n_args, const mp_obj_t *args) {
|
|||
size_t len;
|
||||
subj.begin = mp_obj_str_get_data(args[1], &len);
|
||||
subj.end = subj.begin + len;
|
||||
#if MICROPY_PY_URE_MATCH_SPAN_START_END
|
||||
if (n_args > 2) {
|
||||
const mp_obj_type_t *self_type = mp_obj_get_type(args[1]);
|
||||
mp_int_t str_len = MP_OBJ_SMALL_INT_VALUE(mp_obj_len_maybe(args[1]));
|
||||
const byte *begin = (const byte *)subj.begin;
|
||||
|
||||
int pos = mp_obj_get_int(args[2]);
|
||||
if (pos >= str_len) {
|
||||
return mp_const_none;
|
||||
}
|
||||
if (pos < 0) {
|
||||
pos = 0;
|
||||
}
|
||||
const byte *pos_ptr = str_index_to_ptr(self_type, begin, len, MP_OBJ_NEW_SMALL_INT(pos), true);
|
||||
|
||||
const byte *endpos_ptr = (const byte *)subj.end;
|
||||
if (n_args > 3) {
|
||||
int endpos = mp_obj_get_int(args[3]);
|
||||
if (endpos <= pos) {
|
||||
return mp_const_none;
|
||||
}
|
||||
// Will cap to length
|
||||
endpos_ptr = str_index_to_ptr(self_type, begin, len, args[3], true);
|
||||
}
|
||||
|
||||
subj.begin = (const char *)pos_ptr;
|
||||
subj.end = (const char *)endpos_ptr;
|
||||
}
|
||||
#endif
|
||||
int caps_num = (self->re.sub + 1) * 2;
|
||||
mp_obj_match_t *match = m_new_obj_var(mp_obj_match_t, char*, caps_num);
|
||||
// cast is a workaround for a bug in msvc: it treats const char** as a const pointer instead of a pointer to pointer to const char
|
||||
|
@ -174,17 +278,138 @@ STATIC mp_obj_t re_split(size_t n_args, const mp_obj_t *args) {
|
|||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(re_split_obj, 2, 3, re_split);
|
||||
|
||||
#if MICROPY_PY_URE_SUB
|
||||
|
||||
STATIC mp_obj_t re_sub_helper(mp_obj_t self_in, size_t n_args, const mp_obj_t *args) {
|
||||
mp_obj_re_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
mp_obj_t replace = args[1];
|
||||
mp_obj_t where = args[2];
|
||||
mp_int_t count = 0;
|
||||
if (n_args > 3) {
|
||||
count = mp_obj_get_int(args[3]);
|
||||
// Note: flags are currently ignored
|
||||
}
|
||||
|
||||
size_t where_len;
|
||||
const char *where_str = mp_obj_str_get_data(where, &where_len);
|
||||
Subject subj;
|
||||
subj.begin = where_str;
|
||||
subj.end = subj.begin + where_len;
|
||||
int caps_num = (self->re.sub + 1) * 2;
|
||||
|
||||
vstr_t vstr_return;
|
||||
vstr_return.buf = NULL; // We'll init the vstr after the first match
|
||||
mp_obj_match_t *match = mp_local_alloc(sizeof(mp_obj_match_t) + caps_num * sizeof(char*));
|
||||
match->base.type = &match_type;
|
||||
match->num_matches = caps_num / 2; // caps_num counts start and end pointers
|
||||
match->str = where;
|
||||
|
||||
for (;;) {
|
||||
// cast is a workaround for a bug in msvc: it treats const char** as a const pointer instead of a pointer to pointer to const char
|
||||
memset((char*)match->caps, 0, caps_num * sizeof(char*));
|
||||
int res = re1_5_recursiveloopprog(&self->re, &subj, match->caps, caps_num, false);
|
||||
|
||||
// If we didn't have a match, or had an empty match, it's time to stop
|
||||
if (!res || match->caps[0] == match->caps[1]) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Initialise the vstr if it's not already
|
||||
if (vstr_return.buf == NULL) {
|
||||
vstr_init(&vstr_return, match->caps[0] - subj.begin);
|
||||
}
|
||||
|
||||
// Add pre-match string
|
||||
vstr_add_strn(&vstr_return, subj.begin, match->caps[0] - subj.begin);
|
||||
|
||||
// Get replacement string
|
||||
const char* repl = mp_obj_str_get_str((mp_obj_is_callable(replace) ? mp_call_function_1(replace, MP_OBJ_FROM_PTR(match)) : replace));
|
||||
|
||||
// Append replacement string to result, substituting any regex groups
|
||||
while (*repl != '\0') {
|
||||
if (*repl == '\\') {
|
||||
++repl;
|
||||
bool is_g_format = false;
|
||||
if (*repl == 'g' && repl[1] == '<') {
|
||||
// Group specified with syntax "\g<number>"
|
||||
repl += 2;
|
||||
is_g_format = true;
|
||||
}
|
||||
|
||||
if ('0' <= *repl && *repl <= '9') {
|
||||
// Group specified with syntax "\g<number>" or "\number"
|
||||
unsigned int match_no = 0;
|
||||
do {
|
||||
match_no = match_no * 10 + (*repl++ - '0');
|
||||
} while ('0' <= *repl && *repl <= '9');
|
||||
if (is_g_format && *repl == '>') {
|
||||
++repl;
|
||||
}
|
||||
|
||||
if (match_no >= (unsigned int)match->num_matches) {
|
||||
nlr_raise(mp_obj_new_exception_arg1(&mp_type_IndexError, MP_OBJ_NEW_SMALL_INT(match_no)));
|
||||
}
|
||||
|
||||
const char *start_match = match->caps[match_no * 2];
|
||||
if (start_match != NULL) {
|
||||
// Add the substring matched by group
|
||||
const char *end_match = match->caps[match_no * 2 + 1];
|
||||
vstr_add_strn(&vstr_return, start_match, end_match - start_match);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Just add the current byte from the replacement string
|
||||
vstr_add_byte(&vstr_return, *repl++);
|
||||
}
|
||||
}
|
||||
|
||||
// Move start pointer to end of last match
|
||||
subj.begin = match->caps[1];
|
||||
|
||||
// Stop substitutions if count was given and gets to 0
|
||||
if (count > 0 && --count == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
mp_local_free(match);
|
||||
|
||||
if (vstr_return.buf == NULL) {
|
||||
// Optimisation for case of no substitutions
|
||||
return where;
|
||||
}
|
||||
|
||||
// Add post-match string
|
||||
vstr_add_strn(&vstr_return, subj.begin, subj.end - subj.begin);
|
||||
|
||||
return mp_obj_new_str_from_vstr(mp_obj_get_type(where), &vstr_return);
|
||||
}
|
||||
|
||||
STATIC mp_obj_t re_sub(size_t n_args, const mp_obj_t *args) {
|
||||
return re_sub_helper(args[0], n_args, args);
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(re_sub_obj, 3, 5, re_sub);
|
||||
|
||||
#endif
|
||||
|
||||
STATIC const mp_rom_map_elem_t re_locals_dict_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR_match), MP_ROM_PTR(&re_match_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_search), MP_ROM_PTR(&re_search_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_split), MP_ROM_PTR(&re_split_obj) },
|
||||
#if MICROPY_PY_URE_SUB
|
||||
{ MP_ROM_QSTR(MP_QSTR_sub), MP_ROM_PTR(&re_sub_obj) },
|
||||
#endif
|
||||
};
|
||||
|
||||
STATIC MP_DEFINE_CONST_DICT(re_locals_dict, re_locals_dict_table);
|
||||
|
||||
STATIC const mp_obj_type_t re_type = {
|
||||
{ &mp_type_type },
|
||||
#if CIRCUITPY
|
||||
.name = MP_QSTR_re,
|
||||
#else
|
||||
.name = MP_QSTR_ure,
|
||||
#endif
|
||||
.print = re_print,
|
||||
.locals_dict = (void*)&re_locals_dict,
|
||||
};
|
||||
|
@ -232,11 +457,26 @@ STATIC mp_obj_t mod_re_search(size_t n_args, const mp_obj_t *args) {
|
|||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_re_search_obj, 2, 4, mod_re_search);
|
||||
|
||||
#if MICROPY_PY_URE_SUB
|
||||
STATIC mp_obj_t mod_re_sub(size_t n_args, const mp_obj_t *args) {
|
||||
mp_obj_t self = mod_re_compile(1, args);
|
||||
return re_sub_helper(self, n_args, args);
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_re_sub_obj, 3, 5, mod_re_sub);
|
||||
#endif
|
||||
|
||||
STATIC const mp_rom_map_elem_t mp_module_re_globals_table[] = {
|
||||
#if CIRCUITPY
|
||||
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_re) },
|
||||
#else
|
||||
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_ure) },
|
||||
#endif
|
||||
{ MP_ROM_QSTR(MP_QSTR_compile), MP_ROM_PTR(&mod_re_compile_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_match), MP_ROM_PTR(&mod_re_match_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_search), MP_ROM_PTR(&mod_re_search_obj) },
|
||||
#if MICROPY_PY_URE_SUB
|
||||
{ MP_ROM_QSTR(MP_QSTR_sub), MP_ROM_PTR(&mod_re_sub_obj) },
|
||||
#endif
|
||||
{ MP_ROM_QSTR(MP_QSTR_DEBUG), MP_ROM_INT(FLAG_DEBUG) },
|
||||
};
|
||||
|
||||
|
|
|
@ -221,6 +221,7 @@ STATIC const mp_rom_map_elem_t ussl_socket_locals_dict_table[] = {
|
|||
STATIC MP_DEFINE_CONST_DICT(ussl_socket_locals_dict, ussl_socket_locals_dict_table);
|
||||
|
||||
STATIC const mp_stream_p_t ussl_socket_stream_p = {
|
||||
MP_PROTO_IMPLEMENT(MP_QSTR_protocol_stream)
|
||||
.read = socket_read,
|
||||
.write = socket_write,
|
||||
.ioctl = socket_ioctl,
|
||||
|
|
|
@ -305,6 +305,7 @@ STATIC const mp_rom_map_elem_t ussl_socket_locals_dict_table[] = {
|
|||
STATIC MP_DEFINE_CONST_DICT(ussl_socket_locals_dict, ussl_socket_locals_dict_table);
|
||||
|
||||
STATIC const mp_stream_p_t ussl_socket_stream_p = {
|
||||
MP_PROTO_IMPLEMENT(MP_QSTR_protocol_stream)
|
||||
.read = socket_read,
|
||||
.write = socket_write,
|
||||
.ioctl = socket_ioctl,
|
||||
|
|
|
@ -76,8 +76,8 @@ STATIC bool time_less_than(struct qentry *item, struct qentry *parent) {
|
|||
return res && res < (MODULO / 2);
|
||||
}
|
||||
|
||||
STATIC mp_obj_t utimeq_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
|
||||
mp_arg_check_num(n_args, n_kw, 1, 1, false);
|
||||
STATIC mp_obj_t utimeq_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
mp_arg_check_num(n_args, kw_args, 1, 1, false);
|
||||
mp_uint_t alloc = mp_obj_get_int(args[0]);
|
||||
mp_obj_utimeq_t *o = m_new_obj_var(mp_obj_utimeq_t, struct qentry, alloc);
|
||||
o->base.type = type;
|
||||
|
|
|
@ -69,8 +69,8 @@ STATIC int read_src_stream(TINF_DATA *data) {
|
|||
return c;
|
||||
}
|
||||
|
||||
STATIC mp_obj_t decompio_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
|
||||
mp_arg_check_num(n_args, n_kw, 1, 2, false);
|
||||
STATIC mp_obj_t decompio_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
mp_arg_check_num(n_args, kw_args, 1, 2, false);
|
||||
mp_get_stream_raise(args[0], MP_STREAM_OP_READ);
|
||||
mp_obj_decompio_t *o = m_new_obj(mp_obj_decompio_t);
|
||||
o->base.type = type;
|
||||
|
@ -134,6 +134,7 @@ STATIC const mp_rom_map_elem_t decompio_locals_dict_table[] = {
|
|||
STATIC MP_DEFINE_CONST_DICT(decompio_locals_dict, decompio_locals_dict_table);
|
||||
|
||||
STATIC const mp_stream_p_t decompio_stream_p = {
|
||||
MP_PROTO_IMPLEMENT(MP_QSTR_protocol_stream)
|
||||
.read = decompio_read,
|
||||
};
|
||||
|
||||
|
|
|
@ -331,6 +331,7 @@ STATIC const mp_rom_map_elem_t webrepl_locals_dict_table[] = {
|
|||
STATIC MP_DEFINE_CONST_DICT(webrepl_locals_dict, webrepl_locals_dict_table);
|
||||
|
||||
STATIC const mp_stream_p_t webrepl_stream_p = {
|
||||
MP_PROTO_IMPLEMENT(MP_QSTR_protocol_stream)
|
||||
.read = webrepl_read,
|
||||
.write = webrepl_write,
|
||||
.ioctl = webrepl_ioctl,
|
||||
|
|
|
@ -57,8 +57,8 @@ typedef struct _mp_obj_websocket_t {
|
|||
|
||||
STATIC mp_uint_t websocket_write(mp_obj_t self_in, const void *buf, mp_uint_t size, int *errcode);
|
||||
|
||||
STATIC mp_obj_t websocket_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
|
||||
mp_arg_check_num(n_args, n_kw, 1, 2, false);
|
||||
STATIC mp_obj_t websocket_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
mp_arg_check_num(n_args, kw_args, 1, 2, false);
|
||||
mp_get_stream_raise(args[0], MP_STREAM_OP_READ | MP_STREAM_OP_WRITE | MP_STREAM_OP_IOCTL);
|
||||
mp_obj_websocket_t *o = m_new_obj(mp_obj_websocket_t);
|
||||
o->base.type = type;
|
||||
|
@ -286,6 +286,7 @@ STATIC const mp_rom_map_elem_t websocket_locals_dict_table[] = {
|
|||
STATIC MP_DEFINE_CONST_DICT(websocket_locals_dict, websocket_locals_dict_table);
|
||||
|
||||
STATIC const mp_stream_p_t websocket_stream_p = {
|
||||
MP_PROTO_IMPLEMENT(MP_QSTR_protocol_stream)
|
||||
.read = websocket_read,
|
||||
.write = websocket_write,
|
||||
.ioctl = websocket_ioctl,
|
||||
|
|
|
@ -10,6 +10,29 @@
|
|||
#define EMIT(at, byte) (code ? (code[at] = byte) : (at))
|
||||
#define PC (prog->bytelen)
|
||||
|
||||
|
||||
static char unescape(char c) {
|
||||
switch (c) {
|
||||
case 'a':
|
||||
return '\a';
|
||||
case 'b':
|
||||
return '\b';
|
||||
case 'f':
|
||||
return '\f';
|
||||
case 'n':
|
||||
return '\n';
|
||||
case 'r':
|
||||
return '\r';
|
||||
case 'v':
|
||||
return '\v';
|
||||
case 'x':
|
||||
return '\\';
|
||||
default:
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static const char *_compilecode(const char *re, ByteProg *prog, int sizecode)
|
||||
{
|
||||
char *code = sizecode ? NULL : prog->insts;
|
||||
|
@ -22,13 +45,16 @@ static const char *_compilecode(const char *re, ByteProg *prog, int sizecode)
|
|||
case '\\':
|
||||
re++;
|
||||
if (!*re) return NULL; // Trailing backslash
|
||||
term = PC;
|
||||
if ((*re | 0x20) == 'd' || (*re | 0x20) == 's' || (*re | 0x20) == 'w') {
|
||||
term = PC;
|
||||
EMIT(PC++, NamedClass);
|
||||
EMIT(PC++, *re);
|
||||
prog->len++;
|
||||
break;
|
||||
} else {
|
||||
EMIT(PC++, Char);
|
||||
EMIT(PC++, unescape(*re));
|
||||
}
|
||||
prog->len++;
|
||||
break;
|
||||
default:
|
||||
term = PC;
|
||||
EMIT(PC++, Char);
|
||||
|
@ -54,11 +80,21 @@ static const char *_compilecode(const char *re, ByteProg *prog, int sizecode)
|
|||
prog->len++;
|
||||
for (cnt = 0; *re != ']'; re++, cnt++) {
|
||||
if (!*re) return NULL;
|
||||
EMIT(PC++, *re);
|
||||
if (*re == '\\') {
|
||||
re += 1;
|
||||
EMIT(PC++, unescape(*re));
|
||||
} else {
|
||||
EMIT(PC++, *re);
|
||||
}
|
||||
if (re[1] == '-' && re[2] != ']') {
|
||||
re += 2;
|
||||
}
|
||||
EMIT(PC++, *re);
|
||||
if (*re == '\\') {
|
||||
re += 1;
|
||||
EMIT(PC++, unescape(*re));
|
||||
} else {
|
||||
EMIT(PC++, *re);
|
||||
}
|
||||
}
|
||||
EMIT(term + 1, cnt);
|
||||
break;
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 0394801933f6e68a5bc7cdb0da76c7884e8cf70a
|
|
@ -126,7 +126,7 @@ mp_import_stat_t mp_vfs_import_stat(const char *path) {
|
|||
}
|
||||
|
||||
// If the mounted object has the VFS protocol, call its import_stat helper
|
||||
const mp_vfs_proto_t *proto = mp_obj_get_type(vfs->obj)->protocol;
|
||||
const mp_vfs_proto_t *proto = (mp_vfs_proto_t*)mp_proto_get(MP_QSTR_protocol_vfs, vfs->obj);
|
||||
if (proto != NULL) {
|
||||
return proto->import_stat(MP_OBJ_TO_PTR(vfs->obj), path_out);
|
||||
}
|
||||
|
@ -176,7 +176,7 @@ mp_obj_t mp_vfs_mount(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args
|
|||
// auto-detect the filesystem and create the corresponding VFS entity.
|
||||
// (At the moment we only support FAT filesystems.)
|
||||
#if MICROPY_VFS_FAT
|
||||
vfs_obj = mp_fat_vfs_type.make_new(&mp_fat_vfs_type, 1, 0, &vfs_obj);
|
||||
vfs_obj = mp_fat_vfs_type.make_new(&mp_fat_vfs_type, 1, &vfs_obj, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include "py/lexer.h"
|
||||
#include "py/obj.h"
|
||||
#include "py/proto.h"
|
||||
|
||||
// return values of mp_vfs_lookup_path
|
||||
// ROOT is 0 so that the default current directory is the root directory
|
||||
|
@ -47,6 +48,7 @@
|
|||
|
||||
// At the moment the VFS protocol just has import_stat, but could be extended to other methods
|
||||
typedef struct _mp_vfs_proto_t {
|
||||
MP_PROTOCOL_HEAD
|
||||
mp_import_stat_t (*import_stat)(void *self, const char *path);
|
||||
} mp_vfs_proto_t;
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
#include "lib/oofatfs/ff.h"
|
||||
#include "extmod/vfs_fat.h"
|
||||
#include "lib/timeutils/timeutils.h"
|
||||
|
||||
#include "supervisor/filesystem.h"
|
||||
#include "supervisor/shared/translate.h"
|
||||
|
||||
#if _MAX_SS == _MIN_SS
|
||||
|
@ -65,8 +65,8 @@ mp_import_stat_t fat_vfs_import_stat(void *vfs_in, const char *path) {
|
|||
return MP_IMPORT_STAT_NO_EXIST;
|
||||
}
|
||||
|
||||
STATIC mp_obj_t fat_vfs_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
|
||||
mp_arg_check_num(n_args, n_kw, 1, 1, false);
|
||||
STATIC mp_obj_t fat_vfs_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
mp_arg_check_num(n_args, kw_args, 1, 1, false);
|
||||
|
||||
// create new object
|
||||
fs_user_mount_t *vfs = m_new_obj(fs_user_mount_t);
|
||||
|
@ -99,6 +99,12 @@ STATIC mp_obj_t fat_vfs_make_new(const mp_obj_type_t *type, size_t n_args, size_
|
|||
return MP_OBJ_FROM_PTR(vfs);
|
||||
}
|
||||
|
||||
STATIC void verify_fs_writable(fs_user_mount_t *vfs) {
|
||||
if (!filesystem_is_writable_by_python(vfs)) {
|
||||
mp_raise_OSError(MP_EROFS);
|
||||
}
|
||||
}
|
||||
|
||||
#if _FS_REENTRANT
|
||||
STATIC mp_obj_t fat_vfs_del(mp_obj_t self_in) {
|
||||
mp_obj_fat_vfs_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
|
@ -111,7 +117,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(fat_vfs_del_obj, fat_vfs_del);
|
|||
|
||||
STATIC mp_obj_t fat_vfs_mkfs(mp_obj_t bdev_in) {
|
||||
// create new object
|
||||
fs_user_mount_t *vfs = MP_OBJ_TO_PTR(fat_vfs_make_new(&mp_fat_vfs_type, 1, 0, &bdev_in));
|
||||
fs_user_mount_t *vfs = MP_OBJ_TO_PTR(fat_vfs_make_new(&mp_fat_vfs_type, 1, &bdev_in, NULL));
|
||||
|
||||
// make the filesystem
|
||||
uint8_t working_buf[_MAX_SS];
|
||||
|
@ -201,6 +207,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(fat_vfs_ilistdir_obj, 1, 2, fat_vfs_i
|
|||
|
||||
STATIC mp_obj_t fat_vfs_remove_internal(mp_obj_t vfs_in, mp_obj_t path_in, mp_int_t attr) {
|
||||
mp_obj_fat_vfs_t *self = MP_OBJ_TO_PTR(vfs_in);
|
||||
verify_fs_writable(self);
|
||||
const char *path = mp_obj_str_get_str(path_in);
|
||||
|
||||
FILINFO fno;
|
||||
|
@ -235,9 +242,26 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(fat_vfs_rmdir_obj, fat_vfs_rmdir);
|
|||
|
||||
STATIC mp_obj_t fat_vfs_rename(mp_obj_t vfs_in, mp_obj_t path_in, mp_obj_t path_out) {
|
||||
mp_obj_fat_vfs_t *self = MP_OBJ_TO_PTR(vfs_in);
|
||||
verify_fs_writable(self);
|
||||
const char *old_path = mp_obj_str_get_str(path_in);
|
||||
const char *new_path = mp_obj_str_get_str(path_out);
|
||||
FRESULT res = f_rename(&self->fatfs, old_path, new_path);
|
||||
|
||||
// Check to see if we're moving a directory into itself. This occurs when we're moving a
|
||||
// directory where the old path is a prefix of the new and the next character is a "/" and thus
|
||||
// preserves the original directory name.
|
||||
FILINFO fno;
|
||||
FRESULT res = f_stat(&self->fatfs, old_path, &fno);
|
||||
if (res != FR_OK) {
|
||||
mp_raise_OSError(fresult_to_errno_table[res]);
|
||||
}
|
||||
if ((fno.fattrib & AM_DIR) != 0 &&
|
||||
strlen(new_path) > strlen(old_path) &&
|
||||
new_path[strlen(old_path)] == '/' &&
|
||||
strncmp(old_path, new_path, strlen(old_path)) == 0) {
|
||||
mp_raise_OSError(MP_EINVAL);
|
||||
}
|
||||
|
||||
res = f_rename(&self->fatfs, old_path, new_path);
|
||||
if (res == FR_EXIST) {
|
||||
// if new_path exists then try removing it (but only if it's a file)
|
||||
fat_vfs_remove_internal(vfs_in, path_out, 0); // 0 == file attribute
|
||||
|
@ -255,6 +279,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_3(fat_vfs_rename_obj, fat_vfs_rename);
|
|||
|
||||
STATIC mp_obj_t fat_vfs_mkdir(mp_obj_t vfs_in, mp_obj_t path_o) {
|
||||
mp_obj_fat_vfs_t *self = MP_OBJ_TO_PTR(vfs_in);
|
||||
verify_fs_writable(self);
|
||||
const char *path = mp_obj_str_get_str(path_o);
|
||||
FRESULT res = f_mkdir(&self->fatfs, path);
|
||||
if (res == FR_OK) {
|
||||
|
@ -320,14 +345,21 @@ STATIC mp_obj_t fat_vfs_stat(mp_obj_t vfs_in, mp_obj_t path_in) {
|
|||
} else {
|
||||
mode |= MP_S_IFREG;
|
||||
}
|
||||
mp_uint_t seconds = timeutils_seconds_since_epoch(
|
||||
1980 + ((fno.fdate >> 9) & 0x7f),
|
||||
(fno.fdate >> 5) & 0x0f,
|
||||
fno.fdate & 0x1f,
|
||||
(fno.ftime >> 11) & 0x1f,
|
||||
(fno.ftime >> 5) & 0x3f,
|
||||
2 * (fno.ftime & 0x1f)
|
||||
);
|
||||
#if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_NONE
|
||||
// On non-longint builds, the number of seconds since 1970 (epoch) is too
|
||||
// large to fit in a smallint, so just return 31-DEC-1999 (0).
|
||||
mp_obj_t seconds = MP_OBJ_NEW_SMALL_INT(946684800);
|
||||
#else
|
||||
mp_obj_t seconds = mp_obj_new_int_from_uint(
|
||||
timeutils_seconds_since_epoch(
|
||||
1980 + ((fno.fdate >> 9) & 0x7f),
|
||||
(fno.fdate >> 5) & 0x0f,
|
||||
fno.fdate & 0x1f,
|
||||
(fno.ftime >> 11) & 0x1f,
|
||||
(fno.ftime >> 5) & 0x3f,
|
||||
2 * (fno.ftime & 0x1f)
|
||||
));
|
||||
#endif
|
||||
t->items[0] = MP_OBJ_NEW_SMALL_INT(mode); // st_mode
|
||||
t->items[1] = MP_OBJ_NEW_SMALL_INT(0); // st_ino
|
||||
t->items[2] = MP_OBJ_NEW_SMALL_INT(0); // st_dev
|
||||
|
@ -335,9 +367,9 @@ STATIC mp_obj_t fat_vfs_stat(mp_obj_t vfs_in, mp_obj_t path_in) {
|
|||
t->items[4] = MP_OBJ_NEW_SMALL_INT(0); // st_uid
|
||||
t->items[5] = MP_OBJ_NEW_SMALL_INT(0); // st_gid
|
||||
t->items[6] = mp_obj_new_int_from_uint(fno.fsize); // st_size
|
||||
t->items[7] = mp_obj_new_int_from_uint(seconds); // st_atime
|
||||
t->items[8] = mp_obj_new_int_from_uint(seconds); // st_mtime
|
||||
t->items[9] = mp_obj_new_int_from_uint(seconds); // st_ctime
|
||||
t->items[7] = seconds; // st_atime
|
||||
t->items[8] = seconds; // st_mtime
|
||||
t->items[9] = seconds; // st_ctime
|
||||
|
||||
return MP_OBJ_FROM_PTR(t);
|
||||
}
|
||||
|
@ -419,6 +451,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(fat_vfs_getlabel_obj, vfs_fat_getlabel);
|
|||
|
||||
STATIC mp_obj_t vfs_fat_setlabel(mp_obj_t self_in, mp_obj_t label_in) {
|
||||
fs_user_mount_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
verify_fs_writable(self);
|
||||
const char *label_str = mp_obj_str_get_str(label_in);
|
||||
FRESULT res = f_setlabel(&self->fatfs, label_str);
|
||||
if (res != FR_OK) {
|
||||
|
@ -462,6 +495,7 @@ STATIC const mp_rom_map_elem_t fat_vfs_locals_dict_table[] = {
|
|||
STATIC MP_DEFINE_CONST_DICT(fat_vfs_locals_dict, fat_vfs_locals_dict_table);
|
||||
|
||||
STATIC const mp_vfs_proto_t fat_vfs_proto = {
|
||||
MP_PROTO_IMPLEMENT(MP_QSTR_protocol_vfs)
|
||||
.import_stat = fat_vfs_import_stat,
|
||||
};
|
||||
|
||||
|
|
|
@ -38,6 +38,8 @@
|
|||
#define FSUSER_NO_FILESYSTEM (0x0008) // the block device has no filesystem on it
|
||||
// Device is writable over USB and read-only to MicroPython.
|
||||
#define FSUSER_USB_WRITABLE (0x0010)
|
||||
// Bit set when the above flag is checked before opening a file for write.
|
||||
#define FSUSER_CONCURRENT_WRITE_PROTECTED (0x0020)
|
||||
|
||||
typedef struct _fs_user_mount_t {
|
||||
mp_obj_base_t base;
|
||||
|
|
|
@ -28,12 +28,14 @@
|
|||
#if MICROPY_VFS && MICROPY_VFS_FAT
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "py/runtime.h"
|
||||
#include "py/stream.h"
|
||||
#include "py/mperrno.h"
|
||||
#include "lib/oofatfs/ff.h"
|
||||
#include "extmod/vfs_fat.h"
|
||||
#include "supervisor/filesystem.h"
|
||||
|
||||
// this table converts from FRESULT to POSIX errno
|
||||
const byte fresult_to_errno_table[20] = {
|
||||
|
@ -186,16 +188,36 @@ STATIC mp_obj_t file_open(fs_user_mount_t *vfs, const mp_obj_type_t *type, mp_ar
|
|||
break;
|
||||
}
|
||||
}
|
||||
assert(vfs != NULL);
|
||||
if ((mode & FA_WRITE) != 0 && !filesystem_is_writable_by_python(vfs)) {
|
||||
mp_raise_OSError(MP_EROFS);
|
||||
}
|
||||
|
||||
pyb_file_obj_t *o = m_new_obj_with_finaliser(pyb_file_obj_t);
|
||||
o->base.type = type;
|
||||
|
||||
const char *fname = mp_obj_str_get_str(args[0].u_obj);
|
||||
assert(vfs != NULL);
|
||||
FRESULT res = f_open(&vfs->fatfs, &o->fp, fname, mode);
|
||||
if (res != FR_OK) {
|
||||
m_del_obj(pyb_file_obj_t, o);
|
||||
mp_raise_OSError(fresult_to_errno_table[res]);
|
||||
mp_raise_OSError_errno_str(fresult_to_errno_table[res], args[0].u_obj);
|
||||
}
|
||||
// If we're reading, turn on fast seek.
|
||||
if (mode == FA_READ) {
|
||||
// one call to determine how much space we need.
|
||||
DWORD temp_table[2];
|
||||
temp_table[0] = 2;
|
||||
o->fp.cltbl = temp_table;
|
||||
f_lseek(&o->fp, CREATE_LINKMAP);
|
||||
DWORD size = (temp_table[0] + 1) * 2;
|
||||
o->fp.cltbl = m_malloc_maybe(size * sizeof(DWORD), false);
|
||||
if (o->fp.cltbl != NULL) {
|
||||
o->fp.cltbl[0] = size;
|
||||
res = f_lseek(&o->fp, CREATE_LINKMAP);
|
||||
if (res != FR_OK) {
|
||||
o->fp.cltbl = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// for 'a' mode, we must begin at the end of the file
|
||||
|
@ -206,9 +228,9 @@ STATIC mp_obj_t file_open(fs_user_mount_t *vfs, const mp_obj_type_t *type, mp_ar
|
|||
return MP_OBJ_FROM_PTR(o);
|
||||
}
|
||||
|
||||
STATIC mp_obj_t file_obj_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t file_obj_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
mp_arg_val_t arg_vals[FILE_OPEN_NUM_ARGS];
|
||||
mp_arg_parse_all_kw_array(n_args, n_kw, args, FILE_OPEN_NUM_ARGS, file_open_args, arg_vals);
|
||||
mp_arg_parse_all(n_args, args, kw_args, FILE_OPEN_NUM_ARGS, file_open_args, arg_vals);
|
||||
return file_open(NULL, type, arg_vals);
|
||||
}
|
||||
|
||||
|
@ -233,6 +255,7 @@ STATIC MP_DEFINE_CONST_DICT(rawfile_locals_dict, rawfile_locals_dict_table);
|
|||
|
||||
#if MICROPY_PY_IO_FILEIO
|
||||
STATIC const mp_stream_p_t fileio_stream_p = {
|
||||
MP_PROTO_IMPLEMENT(MP_QSTR_protocol_stream)
|
||||
.read = file_obj_read,
|
||||
.write = file_obj_write,
|
||||
.ioctl = file_obj_ioctl,
|
||||
|
@ -251,6 +274,7 @@ const mp_obj_type_t mp_type_vfs_fat_fileio = {
|
|||
#endif
|
||||
|
||||
STATIC const mp_stream_p_t textio_stream_p = {
|
||||
MP_PROTO_IMPLEMENT(MP_QSTR_protocol_stream)
|
||||
.read = file_obj_read,
|
||||
.write = file_obj_write,
|
||||
.ioctl = file_obj_ioctl,
|
||||
|
|
|
@ -90,8 +90,8 @@ STATIC mp_import_stat_t mp_vfs_posix_import_stat(void *self_in, const char *path
|
|||
return MP_IMPORT_STAT_NO_EXIST;
|
||||
}
|
||||
|
||||
STATIC mp_obj_t vfs_posix_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
|
||||
mp_arg_check_num(n_args, n_kw, 0, 1, false);
|
||||
STATIC mp_obj_t vfs_posix_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
mp_arg_check_num(n_args, kw_args, 0, 1, false);
|
||||
|
||||
mp_obj_vfs_posix_t *vfs = m_new_obj(mp_obj_vfs_posix_t);
|
||||
vfs->base.type = type;
|
||||
|
@ -350,6 +350,7 @@ STATIC const mp_rom_map_elem_t vfs_posix_locals_dict_table[] = {
|
|||
STATIC MP_DEFINE_CONST_DICT(vfs_posix_locals_dict, vfs_posix_locals_dict_table);
|
||||
|
||||
STATIC const mp_vfs_proto_t vfs_posix_proto = {
|
||||
MP_PROTO_IMPLEMENT(MP_QSTR_protocol_vfs)
|
||||
.import_stat = mp_vfs_posix_import_stat,
|
||||
};
|
||||
|
||||
|
|
|
@ -109,14 +109,14 @@ mp_obj_t mp_vfs_posix_file_open(const mp_obj_type_t *type, mp_obj_t file_in, mp_
|
|||
return MP_OBJ_FROM_PTR(o);
|
||||
}
|
||||
|
||||
STATIC mp_obj_t vfs_posix_file_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t vfs_posix_file_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
{ MP_QSTR_file, MP_ARG_OBJ | MP_ARG_REQUIRED, {.u_rom_obj = MP_ROM_PTR(&mp_const_none_obj)} },
|
||||
{ MP_QSTR_mode, MP_ARG_OBJ, {.u_rom_obj = MP_ROM_QSTR(MP_QSTR_r)} },
|
||||
};
|
||||
|
||||
mp_arg_val_t arg_vals[MP_ARRAY_SIZE(allowed_args)];
|
||||
mp_arg_parse_all_kw_array(n_args, n_kw, args, MP_ARRAY_SIZE(allowed_args), allowed_args, arg_vals);
|
||||
mp_arg_parse_all(n_args, args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, arg_vals);
|
||||
return mp_vfs_posix_file_open(type, arg_vals[0].u_obj, arg_vals[1].u_obj);
|
||||
}
|
||||
|
||||
|
@ -220,6 +220,7 @@ STATIC MP_DEFINE_CONST_DICT(rawfile_locals_dict, rawfile_locals_dict_table);
|
|||
|
||||
#if MICROPY_PY_IO_FILEIO
|
||||
STATIC const mp_stream_p_t fileio_stream_p = {
|
||||
MP_PROTO_IMPLEMENT(MP_QSTR_protocol_stream)
|
||||
.read = vfs_posix_file_read,
|
||||
.write = vfs_posix_file_write,
|
||||
.ioctl = vfs_posix_file_ioctl,
|
||||
|
@ -238,6 +239,7 @@ const mp_obj_type_t mp_type_vfs_posix_fileio = {
|
|||
#endif
|
||||
|
||||
STATIC const mp_stream_p_t textio_stream_p = {
|
||||
MP_PROTO_IMPLEMENT(MP_QSTR_protocol_stream)
|
||||
.read = vfs_posix_file_read,
|
||||
.write = vfs_posix_file_write,
|
||||
.ioctl = vfs_posix_file_ioctl,
|
||||
|
|
|
@ -25,15 +25,16 @@
|
|||
*/
|
||||
|
||||
#include "extmod/virtpin.h"
|
||||
#include "py/proto.h"
|
||||
|
||||
int mp_virtual_pin_read(mp_obj_t pin) {
|
||||
mp_obj_base_t* s = (mp_obj_base_t*)MP_OBJ_TO_PTR(pin);
|
||||
mp_pin_p_t *pin_p = (mp_pin_p_t*)s->type->protocol;
|
||||
const mp_pin_p_t *pin_p = mp_proto_get(MP_QSTR_protocol_pin, s);
|
||||
return pin_p->ioctl(pin, MP_PIN_READ, 0, NULL);
|
||||
}
|
||||
|
||||
void mp_virtual_pin_write(mp_obj_t pin, int value) {
|
||||
mp_obj_base_t* s = (mp_obj_base_t*)MP_OBJ_TO_PTR(pin);
|
||||
mp_pin_p_t *pin_p = (mp_pin_p_t*)s->type->protocol;
|
||||
const mp_pin_p_t *pin_p = mp_proto_get(MP_QSTR_protocol_pin, s);
|
||||
pin_p->ioctl(pin, MP_PIN_WRITE, value, NULL);
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#define MICROPY_INCLUDED_EXTMOD_VIRTPIN_H
|
||||
|
||||
#include "py/obj.h"
|
||||
#include "py/proto.h"
|
||||
|
||||
#define MP_PIN_READ (1)
|
||||
#define MP_PIN_WRITE (2)
|
||||
|
@ -35,6 +36,7 @@
|
|||
|
||||
// Pin protocol
|
||||
typedef struct _mp_pin_p_t {
|
||||
MP_PROTOCOL_HEAD
|
||||
mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode);
|
||||
} mp_pin_p_t;
|
||||
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 5d584576ef79ca36506e6c7470e7ac5204cf0a8d
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 3ffb3f02d2046910e09d1f5a74721bd1a4cdf8cf
|
|
@ -1 +1 @@
|
|||
Subproject commit d86fc7e81d51465ca1eae6f8c1141f81f065f5aa
|
||||
Subproject commit e9411c4244984b69ec6928370ede40cec014c10b
|
|
@ -1 +1 @@
|
|||
Subproject commit f4ee725fb93fd1a31666d3f71d10c94eb96df7c8
|
||||
Subproject commit e9f15d61502f34173912ba271aaaf9446dae8da1
|
|
@ -1 +1 @@
|
|||
Subproject commit 412392c8bdb6b4378e007eb7974c76b92fa9ff1d
|
||||
Subproject commit 0e1230676a54da17a309d1dfffdd7fa90240191c
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 7914a6390318687bb8e2e9c4119aa932fea01531
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 0d49a1fcd96c13a94e8bdf26f92abe79b8517906
|
|
@ -1 +1 @@
|
|||
Subproject commit 03c24157d46672c723021686f7a838cfeb2db2ba
|
||||
Subproject commit f4f66fa03990428c239eac68d37f79a7245b4cd3
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 94b03517c1f4ff68cc2bb09b0963f7e7e3ce3d04
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 72968d3546f9d6c5af138d4c179343007cb9662c
|
|
@ -1 +1 @@
|
|||
Subproject commit f5e70e09250f2a25ebb6487a30a763041644c5d3
|
||||
Subproject commit 65fb213b8c554181d54b77f75335e16e2f4c0987
|
|
@ -1 +1 @@
|
|||
Subproject commit ec11164ec6682094a48d0f9848d2c4c89c08f3bc
|
||||
Subproject commit d435fc9a9d90cb063608ae037bf5284b33bc5e84
|
|
@ -1 +1 @@
|
|||
Subproject commit 6298cd363811ad6ac10d4325c898be87a70d7bb2
|
||||
Subproject commit 457aba6dd59ad00502b80c9031655d3d26ecc82b
|
|
@ -0,0 +1 @@
|
|||
Subproject commit ee8f2187d4795b08ae4aa60558f564d26c997be9
|
|
@ -1 +1 @@
|
|||
Subproject commit 4421e79661002ff8da6c0c4f22940ec843ee300b
|
||||
Subproject commit 5fd72fb963c4a0318d29282ca2cc988f19787fda
|
|
@ -1 +1 @@
|
|||
Subproject commit 72e8f3855ecd136641d536a49311c38ee4f76f33
|
||||
Subproject commit 59add970cc66f9b0f2d45082e86b25650843a159
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 56358b4494da825cd99a56a854119f926abca670
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 41de8b3c05dd78d7be8893a0f6cb47a7e9b421a2
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 96ee9954a3099ee9c9d7d7b7747f30ab3c6a45bf
|
|
@ -1 +1 @@
|
|||
Subproject commit eae584918e72ff5fa323825470f276b31829ef9f
|
||||
Subproject commit b5bbdbd56ca205c581ba2c84d927ef99befce88e
|
|
@ -1 +1 @@
|
|||
Subproject commit c92c22ff029ee05bd392299cf25887e9af48903a
|
||||
Subproject commit 76c0dd13294ce8ae0518cb9882dcad5d3668977e
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 0d2c083a2fb57a1562d4806775f45273abbfbfae
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 87755e088150cc9bce42f4104cbd74d91b923c6f
|
|
@ -17,22 +17,22 @@
|
|||
*
|
||||
* Developed at SunPro, a Sun Microsystems, Inc. business.
|
||||
* Permission to use, copy, modify, and distribute this
|
||||
* software is freely granted, provided that this notice
|
||||
* software is freely granted, provided that this notice
|
||||
* is preserved.
|
||||
* ====================================================
|
||||
*
|
||||
*/
|
||||
|
||||
/* __ieee754_rem_pio2f(x,y)
|
||||
*
|
||||
* return the remainder of x rem pi/2 in y[0]+y[1]
|
||||
*
|
||||
* return the remainder of x rem pi/2 in y[0]+y[1]
|
||||
* use __kernel_rem_pio2f()
|
||||
*/
|
||||
|
||||
#include "fdlibm.h"
|
||||
|
||||
/*
|
||||
* Table of constants for 2/pi, 396 Hex digits (476 decimal) of 2/pi
|
||||
* Table of constants for 2/pi, 396 Hex digits (476 decimal) of 2/pi
|
||||
*/
|
||||
#ifdef __STDC__
|
||||
static const __int32_t two_over_pi[] = {
|
||||
|
@ -40,27 +40,27 @@ static const __int32_t two_over_pi[] = {
|
|||
static __int32_t two_over_pi[] = {
|
||||
#endif
|
||||
0xA2, 0xF9, 0x83, 0x6E, 0x4E, 0x44, 0x15, 0x29, 0xFC,
|
||||
0x27, 0x57, 0xD1, 0xF5, 0x34, 0xDD, 0xC0, 0xDB, 0x62,
|
||||
0x27, 0x57, 0xD1, 0xF5, 0x34, 0xDD, 0xC0, 0xDB, 0x62,
|
||||
0x95, 0x99, 0x3C, 0x43, 0x90, 0x41, 0xFE, 0x51, 0x63,
|
||||
0xAB, 0xDE, 0xBB, 0xC5, 0x61, 0xB7, 0x24, 0x6E, 0x3A,
|
||||
0xAB, 0xDE, 0xBB, 0xC5, 0x61, 0xB7, 0x24, 0x6E, 0x3A,
|
||||
0x42, 0x4D, 0xD2, 0xE0, 0x06, 0x49, 0x2E, 0xEA, 0x09,
|
||||
0xD1, 0x92, 0x1C, 0xFE, 0x1D, 0xEB, 0x1C, 0xB1, 0x29,
|
||||
0xD1, 0x92, 0x1C, 0xFE, 0x1D, 0xEB, 0x1C, 0xB1, 0x29,
|
||||
0xA7, 0x3E, 0xE8, 0x82, 0x35, 0xF5, 0x2E, 0xBB, 0x44,
|
||||
0x84, 0xE9, 0x9C, 0x70, 0x26, 0xB4, 0x5F, 0x7E, 0x41,
|
||||
0x84, 0xE9, 0x9C, 0x70, 0x26, 0xB4, 0x5F, 0x7E, 0x41,
|
||||
0x39, 0x91, 0xD6, 0x39, 0x83, 0x53, 0x39, 0xF4, 0x9C,
|
||||
0x84, 0x5F, 0x8B, 0xBD, 0xF9, 0x28, 0x3B, 0x1F, 0xF8,
|
||||
0x84, 0x5F, 0x8B, 0xBD, 0xF9, 0x28, 0x3B, 0x1F, 0xF8,
|
||||
0x97, 0xFF, 0xDE, 0x05, 0x98, 0x0F, 0xEF, 0x2F, 0x11,
|
||||
0x8B, 0x5A, 0x0A, 0x6D, 0x1F, 0x6D, 0x36, 0x7E, 0xCF,
|
||||
0x8B, 0x5A, 0x0A, 0x6D, 0x1F, 0x6D, 0x36, 0x7E, 0xCF,
|
||||
0x27, 0xCB, 0x09, 0xB7, 0x4F, 0x46, 0x3F, 0x66, 0x9E,
|
||||
0x5F, 0xEA, 0x2D, 0x75, 0x27, 0xBA, 0xC7, 0xEB, 0xE5,
|
||||
0x5F, 0xEA, 0x2D, 0x75, 0x27, 0xBA, 0xC7, 0xEB, 0xE5,
|
||||
0xF1, 0x7B, 0x3D, 0x07, 0x39, 0xF7, 0x8A, 0x52, 0x92,
|
||||
0xEA, 0x6B, 0xFB, 0x5F, 0xB1, 0x1F, 0x8D, 0x5D, 0x08,
|
||||
0xEA, 0x6B, 0xFB, 0x5F, 0xB1, 0x1F, 0x8D, 0x5D, 0x08,
|
||||
0x56, 0x03, 0x30, 0x46, 0xFC, 0x7B, 0x6B, 0xAB, 0xF0,
|
||||
0xCF, 0xBC, 0x20, 0x9A, 0xF4, 0x36, 0x1D, 0xA9, 0xE3,
|
||||
0xCF, 0xBC, 0x20, 0x9A, 0xF4, 0x36, 0x1D, 0xA9, 0xE3,
|
||||
0x91, 0x61, 0x5E, 0xE6, 0x1B, 0x08, 0x65, 0x99, 0x85,
|
||||
0x5F, 0x14, 0xA0, 0x68, 0x40, 0x8D, 0xFF, 0xD8, 0x80,
|
||||
0x5F, 0x14, 0xA0, 0x68, 0x40, 0x8D, 0xFF, 0xD8, 0x80,
|
||||
0x4D, 0x73, 0x27, 0x31, 0x06, 0x06, 0x15, 0x56, 0xCA,
|
||||
0x73, 0xA8, 0xC9, 0x60, 0xE2, 0x7B, 0xC0, 0x8C, 0x6B,
|
||||
0x73, 0xA8, 0xC9, 0x60, 0xE2, 0x7B, 0xC0, 0x8C, 0x6B,
|
||||
};
|
||||
|
||||
/* This array is like the one in e_rem_pio2.c, but the numbers are
|
||||
|
@ -89,9 +89,9 @@ static __int32_t npio2_hw[] = {
|
|||
*/
|
||||
|
||||
#ifdef __STDC__
|
||||
static const float
|
||||
static const float
|
||||
#else
|
||||
static float
|
||||
static float
|
||||
#endif
|
||||
zero = 0.0000000000e+00, /* 0x00000000 */
|
||||
half = 5.0000000000e-01, /* 0x3f000000 */
|
||||
|
@ -121,7 +121,7 @@ pio2_3t = 6.1232342629e-17; /* 0x248d3132 */
|
|||
if(ix<=0x3f490fd8) /* |x| ~<= pi/4 , no need for reduction */
|
||||
{y[0] = x; y[1] = 0; return 0;}
|
||||
if(ix<0x4016cbe4) { /* |x| < 3pi/4, special case with n=+-1 */
|
||||
if(hx>0) {
|
||||
if(hx>0) {
|
||||
z = x - pio2_1;
|
||||
if((ix&0xfffffff0)!=0x3fc90fd0) { /* 24+24 bit pi OK */
|
||||
y[0] = z - pio2_1t;
|
||||
|
@ -151,27 +151,27 @@ pio2_3t = 6.1232342629e-17; /* 0x248d3132 */
|
|||
fn = (float)n;
|
||||
r = t-fn*pio2_1;
|
||||
w = fn*pio2_1t; /* 1st round good to 40 bit */
|
||||
if(n<32&&(__int32_t)(ix&0xffffff00)!=npio2_hw[n-1]) {
|
||||
if(n<32&&(__int32_t)(ix&0xffffff00)!=npio2_hw[n-1]) {
|
||||
y[0] = r-w; /* quick check no cancellation */
|
||||
} else {
|
||||
__uint32_t high;
|
||||
j = ix>>23;
|
||||
y[0] = r-w;
|
||||
y[0] = r-w;
|
||||
GET_FLOAT_WORD(high,y[0]);
|
||||
i = j-((high>>23)&0xff);
|
||||
if(i>8) { /* 2nd iteration needed, good to 57 */
|
||||
t = r;
|
||||
w = fn*pio2_2;
|
||||
w = fn*pio2_2;
|
||||
r = t-w;
|
||||
w = fn*pio2_2t-((t-r)-w);
|
||||
w = fn*pio2_2t-((t-r)-w);
|
||||
y[0] = r-w;
|
||||
GET_FLOAT_WORD(high,y[0]);
|
||||
i = j-((high>>23)&0xff);
|
||||
if(i>25) { /* 3rd iteration need, 74 bits acc */
|
||||
t = r; /* will cover all possible cases */
|
||||
w = fn*pio2_3;
|
||||
w = fn*pio2_3;
|
||||
r = t-w;
|
||||
w = fn*pio2_3t-((t-r)-w);
|
||||
w = fn*pio2_3t-((t-r)-w);
|
||||
y[0] = r-w;
|
||||
}
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ pio2_3t = 6.1232342629e-17; /* 0x248d3132 */
|
|||
if(hx<0) {y[0] = -y[0]; y[1] = -y[1]; return -n;}
|
||||
else return n;
|
||||
}
|
||||
/*
|
||||
/*
|
||||
* all other (large) arguments
|
||||
*/
|
||||
if(!FLT_UWORD_IS_FINITE(ix)) {
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
*
|
||||
* Developed at SunPro, a Sun Microsystems, Inc. business.
|
||||
* Permission to use, copy, modify, and distribute this
|
||||
* software is freely granted, provided that this notice
|
||||
* software is freely granted, provided that this notice
|
||||
* is preserved.
|
||||
* ====================================================
|
||||
*/
|
||||
|
@ -74,12 +74,12 @@ float sqrtf(float x)
|
|||
r = 0x01000000L; /* r = moving bit from right to left */
|
||||
|
||||
while(r!=0) {
|
||||
t = s+r;
|
||||
if(t<=ix) {
|
||||
s = t+r;
|
||||
ix -= t;
|
||||
q += r;
|
||||
}
|
||||
t = s+r;
|
||||
if(t<=ix) {
|
||||
s = t+r;
|
||||
ix -= t;
|
||||
q += r;
|
||||
}
|
||||
ix += ix;
|
||||
r>>=1;
|
||||
}
|
||||
|
|
|
@ -17,20 +17,21 @@
|
|||
*
|
||||
* Developed at SunPro, a Sun Microsystems, Inc. business.
|
||||
* Permission to use, copy, modify, and distribute this
|
||||
* software is freely granted, provided that this notice
|
||||
* software is freely granted, provided that this notice
|
||||
* is preserved.
|
||||
* ====================================================
|
||||
*
|
||||
*/
|
||||
|
||||
#include "fdlibm.h"
|
||||
#pragma GCC diagnostic ignored "-Wfloat-equal"
|
||||
|
||||
#define __ieee754_logf logf
|
||||
|
||||
#ifdef __STDC__
|
||||
static const float
|
||||
static const float
|
||||
#else
|
||||
static float
|
||||
static float
|
||||
#endif
|
||||
two23= 8.3886080000e+06, /* 0x4b000000 */
|
||||
half= 5.0000000000e-01, /* 0x3f000000 */
|
||||
|
@ -143,9 +144,9 @@ static float zero= 0.0000000000e+00;
|
|||
}
|
||||
switch (n) {
|
||||
case 0: y = __kernel_sinf(pi*y,zero,0); break;
|
||||
case 1:
|
||||
case 1:
|
||||
case 2: y = __kernel_cosf(pi*((float)0.5-y),zero); break;
|
||||
case 3:
|
||||
case 3:
|
||||
case 4: y = __kernel_sinf(pi*(one-y),zero,0); break;
|
||||
case 5:
|
||||
case 6: y = -__kernel_cosf(pi*(y-(float)1.5),zero); break;
|
||||
|
@ -218,7 +219,7 @@ static float zero= 0.0000000000e+00;
|
|||
p3 = t2+w*(t5+w*(t8+w*(t11+w*t14)));
|
||||
p = z*p1-(tt-w*(p2+y*p3));
|
||||
r += (tf + p); break;
|
||||
case 2:
|
||||
case 2:
|
||||
p1 = y*(u0+y*(u1+y*(u2+y*(u3+y*(u4+y*u5)))));
|
||||
p2 = one+y*(v1+y*(v2+y*(v3+y*(v4+y*v5))));
|
||||
r += (-(float)0.5*y + p1/p2);
|
||||
|
@ -247,7 +248,7 @@ static float zero= 0.0000000000e+00;
|
|||
y = z*z;
|
||||
w = w0+z*(w1+y*(w2+y*(w3+y*(w4+y*(w5+y*w6)))));
|
||||
r = (x-half)*(t-one)+w;
|
||||
} else
|
||||
} else
|
||||
/* 2**58 <= x <= inf */
|
||||
r = x*(__ieee754_logf(x)-one);
|
||||
if(hx<0) r = nadj - r;
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*
|
||||
* Developed at SunPro, a Sun Microsystems, Inc. business.
|
||||
* Permission to use, copy, modify, and distribute this
|
||||
* software is freely granted, provided that this notice
|
||||
* software is freely granted, provided that this notice
|
||||
* is preserved.
|
||||
* ====================================================
|
||||
*/
|
||||
|
@ -136,12 +136,12 @@
|
|||
#define __P(p) ()
|
||||
#endif
|
||||
|
||||
/*
|
||||
/*
|
||||
* set X_TLOSS = pi*2**52, which is possibly defined in <values.h>
|
||||
* (one may replace the following line by "#include <values.h>")
|
||||
*/
|
||||
|
||||
#define X_TLOSS 1.41484755040568800000e+16
|
||||
#define X_TLOSS 1.41484755040568800000e+16
|
||||
|
||||
/* Functions that are not documented, and are not in <math.h>. */
|
||||
|
||||
|
@ -154,13 +154,13 @@ extern float scalbf __P((float, float));
|
|||
extern float significandf __P((float));
|
||||
|
||||
/* ieee style elementary float functions */
|
||||
extern float __ieee754_sqrtf __P((float));
|
||||
extern float __ieee754_acosf __P((float));
|
||||
extern float __ieee754_acoshf __P((float));
|
||||
extern float __ieee754_logf __P((float));
|
||||
extern float __ieee754_atanhf __P((float));
|
||||
extern float __ieee754_asinf __P((float));
|
||||
extern float __ieee754_atan2f __P((float,float));
|
||||
extern float __ieee754_sqrtf __P((float));
|
||||
extern float __ieee754_acosf __P((float));
|
||||
extern float __ieee754_acoshf __P((float));
|
||||
extern float __ieee754_logf __P((float));
|
||||
extern float __ieee754_atanhf __P((float));
|
||||
extern float __ieee754_asinf __P((float));
|
||||
extern float __ieee754_atan2f __P((float,float));
|
||||
extern float __ieee754_expf __P((float));
|
||||
extern float __ieee754_coshf __P((float));
|
||||
extern float __ieee754_fmodf __P((float,float));
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
*
|
||||
* Developed at SunPro, a Sun Microsystems, Inc. business.
|
||||
* Permission to use, copy, modify, and distribute this
|
||||
* software is freely granted, provided that this notice
|
||||
* software is freely granted, provided that this notice
|
||||
* is preserved.
|
||||
* ====================================================
|
||||
*/
|
||||
|
@ -25,9 +25,9 @@
|
|||
#include "fdlibm.h"
|
||||
|
||||
#ifdef __STDC__
|
||||
static const float
|
||||
static const float
|
||||
#else
|
||||
static float
|
||||
static float
|
||||
#endif
|
||||
one = 1.0000000000e+00, /* 0x3f800000 */
|
||||
C1 = 4.1666667908e-02, /* 0x3d2aaaab */
|
||||
|
@ -53,7 +53,7 @@ C6 = -1.1359647598e-11; /* 0xad47d74e */
|
|||
}
|
||||
z = x*x;
|
||||
r = z*(C1+z*(C2+z*(C3+z*(C4+z*(C5+z*C6)))));
|
||||
if(ix < 0x3e99999a) /* if |x| < 0.3 */
|
||||
if(ix < 0x3e99999a) /* if |x| < 0.3 */
|
||||
return one - ((float)0.5*z - (z*r - x*y));
|
||||
else {
|
||||
if(ix > 0x3f480000) { /* x > 0.78125 */
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
*
|
||||
* Developed at SunPro, a Sun Microsystems, Inc. business.
|
||||
* Permission to use, copy, modify, and distribute this
|
||||
* software is freely granted, provided that this notice
|
||||
* software is freely granted, provided that this notice
|
||||
* is preserved.
|
||||
* ====================================================
|
||||
*/
|
||||
|
@ -30,7 +30,7 @@
|
|||
#ifdef __STDC__
|
||||
static const int init_jk[] = {4,7,9}; /* initial value for jk */
|
||||
#else
|
||||
static int init_jk[] = {4,7,9};
|
||||
static int init_jk[] = {4,7,9};
|
||||
#endif
|
||||
|
||||
#ifdef __STDC__
|
||||
|
@ -52,9 +52,9 @@ static float PIo2[] = {
|
|||
};
|
||||
|
||||
#ifdef __STDC__
|
||||
static const float
|
||||
static const float
|
||||
#else
|
||||
static float
|
||||
static float
|
||||
#endif
|
||||
zero = 0.0,
|
||||
one = 1.0,
|
||||
|
@ -62,9 +62,9 @@ two8 = 2.5600000000e+02, /* 0x43800000 */
|
|||
twon8 = 3.9062500000e-03; /* 0x3b800000 */
|
||||
|
||||
#ifdef __STDC__
|
||||
int __kernel_rem_pio2f(float *x, float *y, int e0, int nx, int prec, const __int32_t *ipio2)
|
||||
int __kernel_rem_pio2f(float *x, float *y, int e0, int nx, int prec, const __int32_t *ipio2)
|
||||
#else
|
||||
int __kernel_rem_pio2f(x,y,e0,nx,prec,ipio2)
|
||||
int __kernel_rem_pio2f(x,y,e0,nx,prec,ipio2)
|
||||
float x[], y[]; int e0,nx,prec; __int32_t ipio2[];
|
||||
#endif
|
||||
{
|
||||
|
@ -109,7 +109,7 @@ recompute:
|
|||
i = (iq[jz-1]>>(8-q0)); n += i;
|
||||
iq[jz-1] -= i<<(8-q0);
|
||||
ih = iq[jz-1]>>(7-q0);
|
||||
}
|
||||
}
|
||||
else if(q0==0) ih = iq[jz-1]>>8;
|
||||
else if(z>=(float)0.5) ih=2;
|
||||
|
||||
|
@ -141,7 +141,7 @@ recompute:
|
|||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wfloat-equal"
|
||||
if(z==zero) {
|
||||
#pragma GCC diagnostic pop
|
||||
#pragma GCC diagnostic pop
|
||||
j = 0;
|
||||
for (i=jz-1;i>=jk;i--) j |= iq[i];
|
||||
if(j==0) { /* need recomputation */
|
||||
|
@ -166,7 +166,7 @@ recompute:
|
|||
while(iq[jz]==0) { jz--; q0-=8;}
|
||||
} else { /* break z into 8-bit if necessary */
|
||||
z = scalbnf(z,-(int)q0);
|
||||
if(z>=two8) {
|
||||
if(z>=two8) {
|
||||
fw = (float)((__int32_t)(twon8*z));
|
||||
iq[jz] = (__int32_t)(z-two8*fw);
|
||||
jz += 1; q0 += 8;
|
||||
|
@ -191,29 +191,29 @@ recompute:
|
|||
case 0:
|
||||
fw = 0.0;
|
||||
for (i=jz;i>=0;i--) fw += fq[i];
|
||||
y[0] = (ih==0)? fw: -fw;
|
||||
y[0] = (ih==0)? fw: -fw;
|
||||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
fw = 0.0;
|
||||
for (i=jz;i>=0;i--) fw += fq[i];
|
||||
y[0] = (ih==0)? fw: -fw;
|
||||
for (i=jz;i>=0;i--) fw += fq[i];
|
||||
y[0] = (ih==0)? fw: -fw;
|
||||
fw = fq[0]-fw;
|
||||
for (i=1;i<=jz;i++) fw += fq[i];
|
||||
y[1] = (ih==0)? fw: -fw;
|
||||
y[1] = (ih==0)? fw: -fw;
|
||||
break;
|
||||
case 3: /* painful */
|
||||
for (i=jz;i>0;i--) {
|
||||
fw = fq[i-1]+fq[i];
|
||||
fw = fq[i-1]+fq[i];
|
||||
fq[i] += fq[i-1]-fw;
|
||||
fq[i-1] = fw;
|
||||
}
|
||||
for (i=jz;i>1;i--) {
|
||||
fw = fq[i-1]+fq[i];
|
||||
fw = fq[i-1]+fq[i];
|
||||
fq[i] += fq[i-1]-fw;
|
||||
fq[i-1] = fw;
|
||||
}
|
||||
for (fw=0.0,i=jz;i>=2;i--) fw += fq[i];
|
||||
for (fw=0.0,i=jz;i>=2;i--) fw += fq[i];
|
||||
if(ih==0) {
|
||||
y[0] = fq[0]; y[1] = fq[1]; y[2] = fw;
|
||||
} else {
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
*
|
||||
* Developed at SunPro, a Sun Microsystems, Inc. business.
|
||||
* Permission to use, copy, modify, and distribute this
|
||||
* software is freely granted, provided that this notice
|
||||
* software is freely granted, provided that this notice
|
||||
* is preserved.
|
||||
* ====================================================
|
||||
*/
|
||||
|
@ -25,9 +25,9 @@
|
|||
#include "fdlibm.h"
|
||||
|
||||
#ifdef __STDC__
|
||||
static const float
|
||||
static const float
|
||||
#else
|
||||
static float
|
||||
static float
|
||||
#endif
|
||||
half = 5.0000000000e-01,/* 0x3f000000 */
|
||||
S1 = -1.6666667163e-01, /* 0xbe2aaaab */
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue