Professional Documents
Culture Documents
Day 2 STM 32 MP 11645040776127
Day 2 STM 32 MP 11645040776127
STM32MP1 Primer
DAY 2 : Swinging Around in the STM32MP1 Device Tree
Sponsored by
Sponsored By
Webinar Logistics
2
Sponsored By
Fred Eady
Visit ‘Lecturer Profile’ in your console for more details.
3
STM32MP1 Primer
Sponsored By
AGENDA
STM32MP157x Raspberry Pi 4B Interface
Linux-Based STM32MP157D Accel 6 click Project
STM32MP157x click Arduino Expansion
Linux-Based STM32MP157F Accel 6 click Project
4
STM32MP1 Primer
Swinging Around in the STM32MP1 Device Tree
Sponsored By
5
STM32MP1 Primer
Swinging Around in the STM32MP1 Device Tree
Sponsored By
6
STM32MP1 Primer
Swinging Around in the STM32MP1 Device Tree
Sponsored By
7
STM32MP1 Primer
Swinging Around in the STM32MP1 Device Tree
Sponsored By
8
STM32MP1 Primer
Swinging Around in the STM32MP1 Device Tree
Linux-Based STM32MP157D Accel 6 click Project Sponsored By
9
STM32MP1 Primer
Swinging Around in the STM32MP1 Device Tree
Linux-Based STM32MP157D Accel 6 click Project Sponsored By
10
STM32MP1 Primer
Swinging Around in the STM32MP1 Device Tree
Linux-Based STM32MP157D Accel 6 click Project Sponsored By
11
STM32MP1 Primer
Swinging Around in the STM32MP1 Device Tree
Linux-Based STM32MP157D Accel 6 click Project Sponsored By
12
STM32MP1 Primer
Swinging Around in the STM32MP1 Device Tree
Linux-Based STM32MP157D Accel 6 click Project Sponsored By
13
STM32MP1 Primer
Swinging Around in the STM32MP1 Device Tree
Linux-Based STM32MP157D Accel 6 click Project Sponsored By
&pinctrl{
~~~~~~~~~~~~
i2c5_pins_mx: i2c5_mx-0 {
.dts
pins {
pinmux = <STM32_PINMUX('A', 11, AF4)>, /* I2C5_SCL */
<STM32_PINMUX('A', 12, AF4)>; /* I2C5_SDA */
bias-disable;
drive-open-drain;
slew-rate = <0>;
Device Tree
};
Compiler
};
i2c5_sleep_pins_mx: i2c5_sleep_mx-0 {
pins {
pinmux = <STM32_PINMUX('A', 11, ANALOG)>, /* I2C5_SCL */
<STM32_PINMUX('A', 12, ANALOG)>; /* I2C5_SDA */
.dtb
};
};
14
STM32MP1 Primer
Swinging Around in the STM32MP1 Device Tree
Linux-Based STM32MP157D Accel 6 click Project Sponsored By
15
STM32MP1 Primer
Swinging Around in the STM32MP1 Device Tree
Linux-Based STM32MP157D Accel 6 click Project Sponsored By
16
STM32MP1 Primer
Swinging Around in the STM32MP1 Device Tree
Linux-Based STM32MP157D Accel 6 click Project Sponsored By
//*******************************************
//* OPEN I2C PORTAL to ACCEL6 CLICK
//*******************************************
void init(void)
{
sprintf(filename,"/dev/i2c-1");
accel6_click = open(filename,O_RDWR);
if(accel6_click < 0)
{
puts("open accel6_click failed\r\n");
exit(1);
}
puts("accel6_click sensor opened\r\n");
if(ioctl(accel6_click,I2C_SLAVE,0x18) < 0)
{
puts("failed to register slave address\r\n");
exit(1);
}
puts("slave address accepted\r\n");
char buf[1] = {0x00};
if(write(accel6_click,buf,1)!=1)
{
puts("initial addr write failed\r\n");
}
17
}
STM32MP1 Primer
Swinging Around in the STM32MP1 Device Tree
Linux-Based STM32MP157D Accel 6 click Project Sponsored By
while(1)
{
msleep(1000);
getAccelData();
accelerationX = parseAccelData(ACC_X_MSB, ACC_X_LSB);
accelerationY = parseAccelData(ACC_Y_MSB, ACC_Y_LSB);
accelerationZ = parseAccelData(ACC_Z_MSB, ACC_Z_LSB);
calculatePitchRoll();
for(i=0;i<9;i++)
{
printf("%02X ",i2cRxPkt[i]);
}
printf("\r\n");
temperatureC = (float) (((int8_t)i2cRxPkt[TEMP_RAW]) * 0.5 + 23);
printf("%03.2f C\r\n",temperatureC);
printf("Pitch = %3.2f degrees\r\n",pitch);
printf("Roll = %3.2f degrees\r\n",roll);
}
}
18
STM32MP1 Primer
Swinging Around in the STM32MP1 Device Tree
Sponsored By
19
STM32MP1 Primer
Swinging Around in the STM32MP1 Device Tree
Sponsored By
20
STM32MP1 Primer
Swinging Around in the STM32MP1 Device Tree
Sponsored By
21
STM32MP1 Primer
Swinging Around in the STM32MP1 Device Tree
Sponsored By
22
STM32MP1 Primer
Swinging Around in the STM32MP1 Device Tree
Linux-Based STM32MP157F Accel 6 click Project Sponsored By
23
STM32MP1 Primer
Swinging Around in the STM32MP1 Device Tree
Linux-Based STM32MP157F Accel 6 click Project Sponsored By
24
STM32MP1 Primer
Swinging Around in the STM32MP1 Device Tree
Linux-Based STM32MP157F Accel 6 click Project Sponsored By
Generate Device Tree Source (.dts) File and Copy it to the dts Directory
25
STM32MP1 Primer
Swinging Around in the STM32MP1 Device Tree
Linux-Based STM32MP157F Accel 6 click Project Sponsored By
Manually Add Device Tree Blob File (.dtb) Entry to Device Tree Blob Makefile
26
STM32MP1 Primer
Swinging Around in the STM32MP1 Device Tree
Linux-Based STM32MP157F Accel 6 click Project Sponsored By
27
STM32MP1 Primer
Swinging Around in the STM32MP1 Device Tree
Linux-Based STM32MP157F Accel 6 click Project Sponsored By
Replace Current stm 32m p157f-dk2.dtb File with Newly Compiled stm 32m p157f-accel6-157f-m x .dtb File
28
STM32MP1 Primer
Swinging Around in the STM32MP1 Device Tree
Linux-Based STM32MP157F Accel 6 click Project Sponsored By
GTK Setup
//**************************************
//* GLOBAL GTK WIDGETS
//**************************************
GtkWidget*windowAccel;
GtkWidget*gridAccelFixed1;
GtkWidget*lblAccelPitch;
GtkWidget*lblAccelRoll;
GtkWidget*lblAccelTemp;
GtkWidget*timer;
GtkBuilder*builder;
gboolean accelTimer_handler(GtkWidget *);
gridAccelFixed1 = GTK_WIDGET(gtk_builder_get_object(builder,
"gridAccelFixed1"));
lblAccelPitch = GTK_WIDGET(gtk_builder_get_object(builder, "lblAccelPitch"));
lblAccelRoll = GTK_WIDGET(gtk_builder_get_object(builder, "lblAccelRoll"));
lblAccelTemp = GTK_WIDGET(gtk_builder_get_object(builder, "lblAccelTemp"));
timer = GTK_WIDGET(gtk_builder_get_object(builder, "timer"));
gtk_widget_show(windowAccel);
g_timeout_add_seconds(1,(GSourceFunc)accelTimer_handler, timer);
gtk_main();
close(accel6_click); 29
return EXIT_SUCCESS;
STM32MP1 Primer
Swinging Around in the STM32MP1 Device Tree
Linux-Based STM32MP157F Accel 6 click Project Sponsored By
30
Sponsored By
To get today’s Project Download Package please send an email request to: therealfredeady@gmail.com 31
Thank You
Sponsored by