Skip to content

ヘッダファイルrtmouse.hを追加(リファクタリング) #91

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
constの定数をrtmouse.hへ移動
  • Loading branch information
YusukeKato committed Oct 28, 2024
commit c889dba342de3e71f3a31a17ff3c403fbdf89e63
34 changes: 2 additions & 32 deletions src/drivers/rtmouse.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,36 +53,6 @@ MODULE_LICENSE("GPL");
MODULE_VERSION("3.3.1");
MODULE_DESCRIPTION("Raspberry Pi Mouse device driver");

/* --- Device Numbers --- */
static const unsigned int NUM_DEV[ID_DEV_SIZE] = {
[ID_DEV_LED] = 4, [ID_DEV_SWITCH] = 3, [ID_DEV_SENSOR] = 1,
[ID_DEV_BUZZER] = 1, [ID_DEV_MOTORRAWR] = 1, [ID_DEV_MOTORRAWL] = 1,
[ID_DEV_MOTOREN] = 1, [ID_DEV_MOTOR] = 1, [ID_DEV_CNT] = 2};

/* --- Device Names --- */
static const char *NAME_DEV[ID_DEV_SIZE] = {
[ID_DEV_LED] = "rtled",
[ID_DEV_SWITCH] = "rtswitch",
[ID_DEV_SENSOR] = "rtlightsensor",
[ID_DEV_BUZZER] = "rtbuzzer",
[ID_DEV_MOTORRAWR] = "rtmotor_raw_r",
[ID_DEV_MOTORRAWL] = "rtmotor_raw_l",
[ID_DEV_MOTOREN] = "rtmotoren",
[ID_DEV_MOTOR] = "rtmotor"};

static const char *NAME_DEV_U[ID_DEV_SIZE] = {
[ID_DEV_LED] = "rtled%u",
[ID_DEV_SWITCH] = "rtswitch%u",
[ID_DEV_SENSOR] = "rtlightsensor%u",
[ID_DEV_BUZZER] = "rtbuzzer%u",
[ID_DEV_MOTORRAWR] = "rtmotor_raw_r%u",
[ID_DEV_MOTORRAWL] = "rtmotor_raw_l%u",
[ID_DEV_MOTOREN] = "rtmotoren%u",
[ID_DEV_MOTOR] = "rtmotor%u"};

static int spi_bus_num = 0;
static int spi_chip_select = 0;

static int _major_dev[ID_DEV_SIZE] = {
[ID_DEV_LED] = DEV_MAJOR, [ID_DEV_SWITCH] = DEV_MAJOR,
[ID_DEV_SENSOR] = DEV_MAJOR, [ID_DEV_BUZZER] = DEV_MAJOR,
Expand Down Expand Up @@ -1354,8 +1324,8 @@ static int mcp3204_init(void)

spi_register_driver(&mcp3204_driver);

mcp3204_info.bus_num = spi_bus_num;
mcp3204_info.chip_select = spi_chip_select;
mcp3204_info.bus_num = SPI_BUS_NUM;
mcp3204_info.chip_select = SPI_CHIP_SELECT;

master = spi_busnum_to_master(mcp3204_info.bus_num);

Expand Down
33 changes: 32 additions & 1 deletion src/drivers/rtmouse.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Raspberry Pi 2 B : 2
// Raspberry Pi 3 B/A+/B+ : 2
// Raspberry Pi 4 B : 4
#define RASPBERRYPI 2
#define RASPBERRYPI 4

/* --- Device ID --- */
#define ID_DEV_LED 0
Expand All @@ -17,6 +17,33 @@
#define ID_DEV_CNT 8
#define ID_DEV_SIZE 9

/* --- Device Numbers --- */
const unsigned int NUM_DEV[ID_DEV_SIZE] = {
[ID_DEV_LED] = 4, [ID_DEV_SWITCH] = 3, [ID_DEV_SENSOR] = 1,
[ID_DEV_BUZZER] = 1, [ID_DEV_MOTORRAWR] = 1, [ID_DEV_MOTORRAWL] = 1,
[ID_DEV_MOTOREN] = 1, [ID_DEV_MOTOR] = 1, [ID_DEV_CNT] = 2};

/* --- Device Names --- */
const char *NAME_DEV[ID_DEV_SIZE] = {
[ID_DEV_LED] = "rtled",
[ID_DEV_SWITCH] = "rtswitch",
[ID_DEV_SENSOR] = "rtlightsensor",
[ID_DEV_BUZZER] = "rtbuzzer",
[ID_DEV_MOTORRAWR] = "rtmotor_raw_r",
[ID_DEV_MOTORRAWL] = "rtmotor_raw_l",
[ID_DEV_MOTOREN] = "rtmotoren",
[ID_DEV_MOTOR] = "rtmotor"};

const char *NAME_DEV_U[ID_DEV_SIZE] = {
[ID_DEV_LED] = "rtled%u",
[ID_DEV_SWITCH] = "rtswitch%u",
[ID_DEV_SENSOR] = "rtlightsensor%u",
[ID_DEV_BUZZER] = "rtbuzzer%u",
[ID_DEV_MOTORRAWR] = "rtmotor_raw_r%u",
[ID_DEV_MOTORRAWL] = "rtmotor_raw_l%u",
[ID_DEV_MOTOREN] = "rtmotoren%u",
[ID_DEV_MOTOR] = "rtmotor%u"};

#define NUM_DEV_TOTAL \
(NUM_DEV[ID_DEV_LED] + NUM_DEV[ID_DEV_SWITCH] + \
NUM_DEV[ID_DEV_SENSOR] + NUM_DEV[ID_DEV_BUZZER] + \
Expand All @@ -28,6 +55,10 @@
#define DEVNAME_CNTL "rtcounter_l"
#define DRIVER_NAME "rtmouse"

/* SPI */
#define SPI_BUS_NUM 0
#define SPI_CHIP_SELECT 0

/* --- Device Major and Minor Numbers --- */
#define DEV_MAJOR 0
#define DEV_MINOR 0
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy