2124 views|1 replies

1w

Posts

25

Resources
The OP
 

[SAMR21 New Gameplay] 24. Usage of I2C [Copy link]

 
This post was last edited by dcexpert on 2019-10-14 09:14

In CircuitPython, I2C, SPI, UART and other functions are provided by the busio module, so you need to import busio before you can use them. Let's first look at the usage of I2C:

import busio
from board import *

i2c = busio.I2C(SCL, SDA)
i2c.try_lock()
i2c.scan()
i2c.unlock()

When using I2C, first define the i2c pins, then lock I2C before accessing the bus, and release the bus after use.

Note : Currently, the busio library of circuitpython does not support software I2C mode, and can only use specific GPIOs. On SAMR21, the default SCL=PA23, SDA=PA22, and other GPIOs can be specified, but there are certain restrictions.


This content is originally created by dcexpert , a user of EEWORLD forum. If you want to reprint or use it for commercial purposes, you must obtain the author's consent and indicate the source

 
 

1w

Posts

25

Resources
2
 

When using I2C, it is important to be aware of the differences between CircuitPython and MicroPython so that you can use MicroPython drivers with CircuitPython and vice versa.

 
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list