write a I2C code for sending data(like sending string or sensor data) from pic microcontroller to arduino? - pic

Write the code using MPLABX IDE ( Can just write the main c code) as i am not understanding the syntax to be used while writing and available functions

Related

Which library to import in micropython to transmit IR code on esp8266?

I am trying to migrate my code that is written in C++ syntax to python syntax. Now my issue is, I am not able to find the right library to import in REPL.
I am trying to transmit RC6 data of length 24. In original code, I have include
#include <IRremoteESP8266.h>
#include <IRsend.h>
//some code
const uint16_t kIrLed = 4; // ESP GPIO pin to use. Recommended: 4 (D2).
IRsend irsend(kIrLed); // Set the GPIO to be used to sending the message.
//some more code
ir.**sendRC6**([code] ,[length]);
Please suggest which library to import, such that I can send the hex data on GPIO D2.
Thanks and Regards,
Shariq

How and where is i2c protocol implemented for master send/receive in linux kernel tree?

Apologies for such a generic title but couldn't think of any better.
I am trying to understand where in drivers/i2c/ is the protocol sequence of sending START, ADDR, DATA, STOP bit sequence implemented, as per the protocol. I want to verify the protocol for send/receive in the driver code, that's all the objective here.
I am using Hikey 620 as a reference which has DesignWare's I2C controller. Below is the registration code I can see (elixir):
static const struct i2c_algorithm i2c_dw_algo = {
.master_xfer = i2c_dw_xfer,
.functionality = i2c_dw_func,
};
If I trace the i2c_dw_xfer function recursively, the last call I could see are readl_relaxed, writel_relaxed in i2c_dw_xfer_init() (elixir).
Beyond this is all assembly. Are these readl/writel the actual sequence of start/data/stop byte sequences? Or am I understanding it totally wrong?
In that case, please help and point me to the correct flow. If what I got is correct, is there some simpler controller code which has a cleaner implementation and can be used as reference.
The protocol itself is not part of the driver code. What the dw_{readl/writel} functions do by calling readl/writel is write to the registers of the I2C peripheral of the concerned SoC. It is the job of the I2C controller on the SoC to then generate the correct I2C signalling. You can see by going through the datasheet that something like DW_IC_CON is a register offset in the I2C peripheral memory map.

PIC MCC i2c HT16K33 problems

Has anyone out there successfully driven an HT16K33 using MCC i2c generated code?
Using my own rudimentary i2c code I can get the HT16K33(link below) to work ok but no matter what I try the MCC i2c code will not work. As a sanity check I have the MCC code working ok with a PCF8574 io expander.
I am testing with a 16F18877 on a breadboard, no schematic, the HT16K33 is on an Adafruit board(link below), all is verified working with my i2c code and the io expander.
The HT16K33 is an LED controller. Requires three i2c commands to test, turn on oscillator, turn on display, and send data to the display ram. Holtek recommends having a 100ms delay at the program entry to allow the chip to start up which I have before any i2c commands. I have boiled this down to the simplest possible test of the MCC code by using my working code for the display on and ram data, only using the MCC code to start the oscillator which is the first step.
I2C1_MESSAGE_STATUS status = I2C1_MESSAGE_PENDING;
I2C1_MasterWrite( 0b00100001, 1, 0x70, &status);
while (I2C1_MESSAGE_PENDING == status);
http://www.holtek.com/documents/10179/116711/HT16K33v120.pdf
https://learn.adafruit.com/assets/32012
Any ideas?

Take GPIO Input on BeagleBone Black in C++

I want to write a program to read a status of a GPIO pin (whether it is high or not) specifically using c++. I know that I have to export it by writing a value in sys/class/gpio and then set its direction as "in". Now I am confused on how to access the interrupt generated on a GPIO pin and do some action in my code with respect to that input.. I dont want to use any custom made library functions.
Thank you.

what does `ioctl` do in `struct tty_driver`?

What does ioctl do in the structure struct tty_driver?
I know the ioctl() function provides the means to control the hardware (Keyboard, Mouse, Print) but for example a driver to control the leds on the keyboard I think that the ioctl is more than enough to do this task...
So why I need a tty_driver? I know tty_driver is a struct
P.D I've never tried to program a Device Driver. I've only read a bit of code in some books.
When developing a new driver, the struct tty_driver structure is used to register a tty_driver (using tty_register_driver() 1). This code creates a new device file and set the file operations to some tty specific functions.
The ioctl entry in the newly created file operations is set to tty_ioctl() 2 which after handling some of the basic commands will call the .ioctl function set in the struct tty_operations 3 referenced in the struct tty_driver.
By defining ioctl (note that it is checked if it is not NULL in 3) the developer can implement ioctl commands specific to its device or simply be notified of some other standard commands.

Resources