JerrySlhao opened a new pull request, #15428: URL: https://github.com/apache/nuttx/pull/15428
add bmi088 device used spi,now support spi. By the way, the STM32G4 series SPI driver is added to the SPI driver of STM32. ## Summary There is no driver of BMI088 in the sensor device driver, I am using this sensor driver, so it is just submitted. ## Impact This part of the code for the system just adds a new device driver function, convenient for everyone to use. ## Testing I used STM32G474 to create the board-level driver in the board directory, registered the bmi088 device driver when bringing up, and then created the test program of bmi088 in nuttx-app/example. ### nuttx-apps/examples/bmi088/bmi088_main.c ``` /**************************************************************************** * apps/system/bmi088/bmi088_main.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. The * ASF licenses this file to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations * under the License. * ****************************************************************************/ /**************************************************************************** * Included Files ****************************************************************************/ #include <nuttx/config.h> #include <nuttx/arch.h> #include <errno.h> #include <sched.h> #include <stdint.h> #include <stdio.h> #include <sys/boardctl.h> #include <sys/stat.h> #include <fcntl.h> #include <nuttx/fs/fs.h> #include <nuttx/semaphore.h> #include <unistd.h> #include <arch/board/board.h> #include <nuttx/sensors/bmi088.h> int bmi088_acc_fd; int bmi088_gyro_fd; struct acc_gyro_st_s acc_gyro; /**************************************************************************** * Public Functions ****************************************************************************/ static int bmi088_acc_irq_handler(int irq, FAR void *context, FAR void *arg) { sem_t *sem; sem = sem_open("/acc_semphore", O_CREAT, S_IRUSR | S_IWUSR, 1); if (sem == SEM_FAILED) { return 1; } sem_post(sem); return 0; } /**************************************************************************** * Public Functions ****************************************************************************/ static void bmi088_acc_irq_handler_process(void) { sem_t *sem; sem = sem_open("/acc_semphore", O_CREAT, S_IRUSR | S_IWUSR, 1); if (sem == SEM_FAILED) { return; } while (1) { sem_wait(sem); read (bmi088_acc_fd , &acc_gyro, sizeof(struct acc_gyro_st_s)); } } /**************************************************************************** * Public Functions ****************************************************************************/ static int bmi088_gyro_irq_handler(int irq, FAR void *context, FAR void *arg) { sem_t *sem; sem = sem_open("/gyro_semphore", O_CREAT, S_IRUSR | S_IWUSR, 1); if (sem == SEM_FAILED) { return 1; } sem_post(sem); return 0; } /**************************************************************************** * Public Functions ****************************************************************************/ static void bmi088_gyro_irq_handler_process(void) { sem_t *sem; sem = sem_open("/gyro_semphore", O_CREAT, S_IRUSR | S_IWUSR, 1); if (sem == SEM_FAILED) { return; } while (1) { sem_wait(sem); read (bmi088_gyro_fd, &acc_gyro, sizeof(struct acc_gyro_st_s)); } } /**************************************************************************** * Name: bmi088_main * * Description: * This is the main logic for the case of the BMI088 task. It will perform * one-time NSH initialization and start an interactive session on the * current console device. * ****************************************************************************/ int main(int argc, FAR char *argv[]) { int ret = 0; bmi088_acc_fd = open("dev/spi2/acc" , O_RDWR); bmi088_gyro_fd = open("dev/spi2/gyro", O_RDWR); bmi088_acc_irq_handler_register (bmi088_acc_irq_handler , &acc_gyro); bmi088_gyro_irq_handler_register(bmi088_gyro_irq_handler, &acc_gyro); pid_t pid; pid = fork(); if (pid == -1) { return 1; } else if (pid == 0) { bmi088_gyro_irq_handler_process(); } else { bmi088_acc_irq_handler_process(); } return ret; } ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org