configs/stm32f103-minimum: Add Nunchuck board support for stm32f103-minimum board
This commit is contained in:
parent
2fb52cf3d9
commit
505358b08f
@ -12,6 +12,7 @@ Contents
|
||||
- UARTs
|
||||
- Timer Inputs/Outputs
|
||||
- Using 128KiB of Flash instead of 64KiB
|
||||
- Nintendo Wii Nunchuck
|
||||
- Quadrature Encoder
|
||||
- SDCard support
|
||||
- SPI NOR Flash
|
||||
@ -245,6 +246,39 @@ Using 128KiB of Flash instead of 64KiB
|
||||
|
||||
Now NuttX should start normally.
|
||||
|
||||
Nintendo Wii Nunchuck:
|
||||
======================
|
||||
|
||||
There is a driver on NuttX to support Nintendo Wii Nunchuck Joystick. If you
|
||||
want to use it please select these options:
|
||||
|
||||
- Enable the I2C1 at System Type -> STM32 Peripheral Support, it will enable:
|
||||
|
||||
CONFIG_STM32_I2C1=y
|
||||
|
||||
- Enable to Custom board/driver initialization at RTOS Features -> RTOS hooks
|
||||
|
||||
CONFIG_BOARD_INITIALIZE=y
|
||||
|
||||
- Enable the I2C Driver Support at Device Drivers, it will enable this symbol:
|
||||
|
||||
CONFIG_I2C=y
|
||||
|
||||
- Nintendo Wii Nunchuck Joystick at Device Drivers -> [*] Input Device Support
|
||||
|
||||
CONFIG_INPUT=y
|
||||
CONFIG_INPUT_NUNCHUCK=y
|
||||
|
||||
- Enable the Nunchuck joystick example at Application Configuration -> Examples
|
||||
|
||||
CONFIG_EXAMPLES_NUNCHUCK=y
|
||||
CONFIG_EXAMPLES_NUNCHUCK_DEVNAME="/dev/nunchuck0"
|
||||
|
||||
You need to connect GND and +3.3V pins from Nunchuck connector to GND and 3.3V
|
||||
of stm32f103-minimum respectively (Nunchuck also can work connected to 5V, but
|
||||
I don't recommend it). Connect I2C Clock from Nunchuck to SCK (PB6) and the
|
||||
I2C Data to SDA (PB7).
|
||||
|
||||
Quadrature Encoder:
|
||||
===================
|
||||
|
||||
|
@ -105,6 +105,10 @@ ifeq ($(CONFIG_LCD_MAX7219),y)
|
||||
CSRCS += stm32_max7219.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_INPUT_NUNCHUCK),y)
|
||||
CSRCS += stm32_nunchuck.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_LCD_ST7567),y)
|
||||
CSRCS += stm32_lcd.c
|
||||
endif
|
||||
|
@ -284,6 +284,16 @@ int stm32_bringup(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_INPUT_NUNCHUCK
|
||||
/* Register the Nunchuck driver */
|
||||
|
||||
ret = nunchuck_initialize("/dev/nunchuck0");
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: nunchuck_initialize() failed: %d\n", ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SENSORS_QENCODER
|
||||
/* Initialize and register the qencoder driver */
|
||||
|
||||
|
99
configs/stm32f103-minimum/src/stm32_nunchuck.c
Normal file
99
configs/stm32f103-minimum/src/stm32_nunchuck.c
Normal file
@ -0,0 +1,99 @@
|
||||
/****************************************************************************
|
||||
* configs/stm32f4discovery/src/stm32_nunchuck.c
|
||||
*
|
||||
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Alan Carvalho de Assis <acassis@gmail.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/fs/fs.h>
|
||||
#include <nuttx/input/nunchuck.h>
|
||||
|
||||
#include "stm32_i2c.h"
|
||||
#include "stm32f103_minimum.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define NUNCHUCK_I2C_PORTNO 1 /* On I2C1 */
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nunchuck_initialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize and register the Nunchuck joystick driver
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int nunchuck_initialize(FAR char *devname)
|
||||
{
|
||||
FAR struct i2c_master_s *i2c;
|
||||
int ret;
|
||||
|
||||
iinfo("Initializing Wii Nunchuck!\n");
|
||||
|
||||
/* Initialize I2C */
|
||||
|
||||
i2c = stm32_i2cbus_initialize(NUNCHUCK_I2C_PORTNO);
|
||||
if (i2c == NULL)
|
||||
{
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
/* Register the joystick device as /dev/nunchuck0 */
|
||||
|
||||
iinfo("Initialize joystick driver: %s\n", devname);
|
||||
|
||||
ret = nunchuck_register(devname, i2c);
|
||||
if (ret < 0)
|
||||
{
|
||||
ierr("ERROR: nunchuck_register failed: %d\n", ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
@ -241,6 +241,18 @@ void stm32_spidev_initialize(void);
|
||||
int stm32_mmcsd_initialize(int minor);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nunchuck_initialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize and register the button joystick driver
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_INPUT_NUNCHUCK
|
||||
int nunchuck_initialize(FAR char *devname);
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
* Name: stm32_hcsr04_initialize
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user