How to Disable Hardware SPI Chip Enable/Chip Select on Raspberry Pi? - linux

I'm setting up a Raspberry Pi 4b with a number of Adafruit chips, and thus have used their CircuitPython library to control SPI communication. They've conveniently set up a way to use any GPIO pins as chip selects, but as a result I had no idea that there are two hardware chip selects on the Raspi (CE0 and CE1 on GPIO8 and GPIO7 respectively). I have already wired these pins (GPIO7&8) with the intention of using them as GPIO outputs, but I've noticed I GPIO8/CE0 is connected to the SPI clock.
Adafruit actually mentions that the NO_CS flag doesn't work in their documentation, and I can't seem to find anything useful online.
How can I disable the hardware CS pins? I know the SPI_NO_CS flag in SPI_MODE is already a bug in the spi-bcm library, and I found this patch, but I'm not sure if it would work (I think CircuitPython utilizes a hardware CS?), let alone how to apply it.

Related

Embedded linux - sysfs - disable pwm pin without disabling the whole channel

I have a raspberry pi, I want to use one single pwm channel to control a rgb led. There are 2 pins available for pwm0. So I connected red led on first pin and green led on second pin. I connected the blue one on a gpio. When I enable pwm0, the red and green leds are on. I would like to control them individually. I know it will be same period and duty cycle but is there a way to turn one pin off without disabling the entire pwm channel ?
You need to provide more information, such as a code snippet, the library you are using and the schematic. You can find more information on this specific stackexchange thread for raspberry: PWM on Raspberry. You must be having trouble configuring your pins. For sure, you are able to do it.

i2cdetect doesn't find anything on goodix chip

I have a goodix chip for the touchscreen on my tablet PC and even though I compiled the latest kernel module for it, things are not working.
I am using exactly this kernel version with the patched driver:
https://github.com/NimbleX/kernel
For starters, the picture of the said chip is the following:
The DSDT tables contain information regarding the touchscreen.
From what I understand the touchscreen is connected via an I2C serial interface but lshw shows that *-serial is UNCLAIMED.
Nevertheless I can see that the i2c_i801 module for the SMBus controller is loaded.
With the help of Aleksei I was able to determine that the toucscreen is connected to i2c-1 buss and that the controller must use 0x14 or 0x5d address.
Unfortunatelly, i2cdetect doesn't find anything, as it can be seen here.
I created a lengthy gist with the output of the following:
dmesg
DSDT.dsl
lshw
lspci
lsusb
/proc/bus/input/devices
xinput
I know that some of these are redundant and that others are useless but nevertheless it's better to have where to search than to miss something out.
I measured with a multimeter and the chip is powered both when running Windows and Linux so this rules out that I need to somehow tell Linux to power this thing out.
So, what do do next in order to debug this thing?
Hi can you check where pin 5,6 are connected specifically 6 which is reset ic so if that may be reseting the ic. just a posiblity.

How to use a MCP23017 with MCP3008 for I2C voltage sensor with Raspberry Pi?

I would like to know if is possible to use an MCP23017 16 bit I/O expander with a MCP3008 ADC and read the voltage with a Raspberry Pi 2. I want to use the ADC as an I2C device. I would like to do this so I don't have to run the program a 'root', so I'm thinking that running the ADC as an I2C device will fix this problem. I'm looking for help with how to wire the system as well as programming it. I'm using the Python 3 editor. The existing program I have will be used to plot a sine wave generated by a AD9850 DDS module who's signal is amplified and fed into a device. I want to measure this voltage. I know how to use a voltage divider, but am having trouble coming up with a way to read it. The measured voltage value needs to be stored as global variable that can be passed around the program. Right now I'm mainly concerned with not running the program as a root, turning the ADC into an i2c device, and storing the voltage as a global variable to be passed around in an existing program.
I have not worked with any kind of I2C TO SPI converter. Still, you can use some I2C to SPI bridges if they work, I just googled it, but that can cause wiring problems.
I can suggest you the same ADC MCP series with I2C interface.Thus, the further I2C connections with MCP23017 expander and then the Raspberry pi would be easy.You can go through various analog to digital converters that can be I2C interfaced with their codes in python or java for pi like MCP3425, MCP3426, MCP3427, MCP3428. You can easily find them or also check control everything as that would be easy to interface using I2C cables and adapters preventing connection or wiring problems.For codes: https://github.com/ControlEverythingCommunity?utf8=%E2%9C%93&query=MCP34
The following codes for MCP_23017 can also help you code the way you want easily with expander being connected to pi:https://github.com/ControlEverythingCommunity/MCP23017_16-Channel.
I think this would solve your problem!!
Thanks.

ARM LPC1751 pins configured as I/O

How can I configure one pin for input and another for the output?
If I am not wrong this could be done with GPIO registers that controlls device pins that are not connected to peripherical functions.
Look in UM10360.PDF, Chapter 9: GPIO. There you can find the description for the FIOxDIR direction registers, as well as the reigisters for querying, setting and clearing GPIO pins.
I also strongly recommend looking at the CMSIS Standard Peripherial Driver Library that NXP offers for 175x/176x, look in microcontroller support documents. Edit: There are lots of sample code in this Library.
https://github.com/dwelch67
I have a number of lpc based examples. You are looking for the IODIR register, depending on the port and flavor of LPC, there are now what they call fast I/O registers. a one in a bit location means that pin is an output, a zero an input.

How would I control the output of the power in USB ports in Linux?

I built a robot from a thin client pc (can run Windows CE or Linux) and two servo motors. I put USB ends on the servo motors, so when they are plugged in to the thin client they continuously run. In Linux, how could I set the amount of current or voltage going from the USB ports to the servo motors? Would I be able to run a shell script to set the power of a certain USB port to slow down a motor or stop one? If this cannot be done through software, what is the easiest way to do this through hardware without having to buy too much?
The USB voltage is fixed at a nominal 5 volts and cannot be controlled.
The behavior of USB devices regarding their current draw is well defined in the USB specifications. USB devices are supposed to draw up to 1 unit load (100mA) unless they have negotiated a higher load from the USB host. It's quite likely that the servo motors that you have are going to need to draw higher currents than that, and wouldn't be able to request it without being a USB device and negotiating with the host.
It's also likely, depending on the servo motor that you are trying to control, that you'll need to either provide a PWM signal or an analogue voltage to control motor position. USB hosts are not intended to provide either of these.
Your best options to drive your motor from your PC are:
Get a dedicated USB controller for your servo motor (if one exists)
Make your own, based on a small microprocessor (eg. using an arduino)
Choose a different port on the PC. If available, PC parallel ports can be controlled to provide control for motor drivers.
The answers here seem to say it is a hardware issue, but I think this is a software issue. ASUS has Ai Charge which more then doubles the volts to charging Apple products from a standard 2.0 usb port.
USB 1.0, 2.0 and 3.0 Specs (All at 5 volts) 4 Wires (2 Data and 2
dedicated power)
Voltage Breakdown: USB 1.0 and USB 2.0 = 0.5A or 500 mA = 2.5 watt
USB 3.0 = 0.9A or 900mA = 4.5 watt Wall wart = 1.5A or 1500 mA = 7.5
watt Ai Charge = 1.2A or 1200mA = 6 watt
Ai Charge works on ASUS and non-ASUS motherboards and is a program you can install in Windows.
Personally I HATE Apple so I want to figure out a way to do this 1.2A usb 2.0 output trick for my netbook while running Linux.
I don't believe it is possible to directly manipulate the USB voltages. They are designed to provide a +5V output at all times unless power is diminised with other hubs.
You might be better served posting this question on http://electronics.stackexchange.com
you need to use PWM to control motors speed, to do that you need a micro controller, PIC18F series supports USB communication, there are plenty of code samples available internet how to use USB in PIC18F series, also you need a transistor array or H-Bridge to control mortors from PIC.
The simplest way to communicate is, program a USB serial in PIC18F micro controller, and when you plug that 18F to your computer, it will detect USB serial port, so you can send the commands to serial port to control speeds.
I dont think its possible, and even if it was, consider this: The USB port is not suposed to power motors because you can burn the USB port. USB is limited to 500mA (or there abouts) and any power device like a motor can potentially require more than that.
Another thing is that servos should be driven with constant voltage, and the speed is controlled by timing impulses on the control wire.
http://en.wikipedia.org/wiki/Pulse-width_modulation
You should use a driver (hardware) to power the motor with an external power source.
This is transistor's purpose, or try with a potentiometer

Resources