mailbox: control LED through the little core
This commit is contained in:
@ -9,14 +9,20 @@
|
|||||||
#define NR_RTOS_CMD 127
|
#define NR_RTOS_CMD 127
|
||||||
#define NR_RTOS_IP IP_LIMIT
|
#define NR_RTOS_IP IP_LIMIT
|
||||||
|
|
||||||
|
|
||||||
enum SYS_CMD_ID {
|
enum SYS_CMD_ID {
|
||||||
CMD_TEST_A = 0x10,
|
CMD_TEST_A = 0x10,
|
||||||
CMD_TEST_B,
|
CMD_TEST_B,
|
||||||
CMD_TEST_C,
|
CMD_TEST_C,
|
||||||
|
CMD_DUO_LED,
|
||||||
SYS_CMD_INFO_LIMIT,
|
SYS_CMD_INFO_LIMIT,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum DUO_LED_STATUS {
|
||||||
|
DUO_LED_ON = 0x02,
|
||||||
|
DUO_LED_OFF,
|
||||||
|
DUO_LED_DONE,
|
||||||
|
};
|
||||||
|
|
||||||
struct valid_t {
|
struct valid_t {
|
||||||
unsigned char linux_valid;
|
unsigned char linux_valid;
|
||||||
unsigned char rtos_valid;
|
unsigned char rtos_valid;
|
||||||
|
|||||||
@ -18,6 +18,8 @@
|
|||||||
#include "comm.h"
|
#include "comm.h"
|
||||||
#include "cvi_spinlock.h"
|
#include "cvi_spinlock.h"
|
||||||
|
|
||||||
|
/* Milk-V Duo */
|
||||||
|
#include "milkv_duo_io.h"
|
||||||
|
|
||||||
// #define __DEBUG__
|
// #define __DEBUG__
|
||||||
#ifdef __DEBUG__
|
#ifdef __DEBUG__
|
||||||
@ -94,7 +96,6 @@ void main_cvirtos(void)
|
|||||||
/* Start the tasks and timer running. */
|
/* Start the tasks and timer running. */
|
||||||
vTaskStartScheduler();
|
vTaskStartScheduler();
|
||||||
|
|
||||||
|
|
||||||
/* If all is well, the scheduler will now be running, and the following
|
/* If all is well, the scheduler will now be running, and the following
|
||||||
line will never be reached. If the following line does execute, then
|
line will never be reached. If the following line does execute, then
|
||||||
there was either insufficient FreeRTOS heap memory available for the idle
|
there was either insufficient FreeRTOS heap memory available for the idle
|
||||||
@ -158,6 +159,19 @@ void prvCmdQuRunTask(void *pvParameters)
|
|||||||
rtos_cmdq.resv.valid.linux_valid = 0;
|
rtos_cmdq.resv.valid.linux_valid = 0;
|
||||||
printf("recv cmd(%d) from C906B...send [0x%x] to C906B\n", rtos_cmdq.cmd_id, rtos_cmdq.param_ptr);
|
printf("recv cmd(%d) from C906B...send [0x%x] to C906B\n", rtos_cmdq.cmd_id, rtos_cmdq.param_ptr);
|
||||||
goto send_label;
|
goto send_label;
|
||||||
|
case CMD_DUO_LED:
|
||||||
|
rtos_cmdq.cmd_id = CMD_DUO_LED;
|
||||||
|
printf("recv cmd(%d) from C906B, param_ptr [0x%x]\n", rtos_cmdq.cmd_id, rtos_cmdq.param_ptr);
|
||||||
|
if (rtos_cmdq.param_ptr == DUO_LED_ON) {
|
||||||
|
duo_led_control(1);
|
||||||
|
} else {
|
||||||
|
duo_led_control(0);
|
||||||
|
}
|
||||||
|
rtos_cmdq.param_ptr = DUO_LED_DONE;
|
||||||
|
rtos_cmdq.resv.valid.rtos_valid = 1;
|
||||||
|
rtos_cmdq.resv.valid.linux_valid = 0;
|
||||||
|
printf("recv cmd(%d) from C906B...send [0x%x] to C906B\n", rtos_cmdq.cmd_id, rtos_cmdq.param_ptr);
|
||||||
|
goto send_label;
|
||||||
default:
|
default:
|
||||||
send_label:
|
send_label:
|
||||||
/* used to send command to linux*/
|
/* used to send command to linux*/
|
||||||
|
|||||||
12
freertos/cvitek/task/comm/src/riscv64/milkv_duo_io.c
Normal file
12
freertos/cvitek/task/comm/src/riscv64/milkv_duo_io.c
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#include "milkv_duo_io.h"
|
||||||
|
|
||||||
|
void duo_led_control(int enable)
|
||||||
|
{
|
||||||
|
*(uint32_t*)(GPIO2 | GPIO_SWPORTA_DDR) = 1 << 24;
|
||||||
|
|
||||||
|
if (enable) {
|
||||||
|
*(uint32_t*)(GPIO2 | GPIO_SWPORTA_DR) = 1 << 24;
|
||||||
|
} else {
|
||||||
|
*(uint32_t*)(GPIO2 | GPIO_SWPORTA_DR) = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
14
freertos/cvitek/task/comm/src/riscv64/milkv_duo_io.h
Normal file
14
freertos/cvitek/task/comm/src/riscv64/milkv_duo_io.h
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
/*
|
||||||
|
* The blue LED on Duo is GPIOC24.
|
||||||
|
* The datasheet page 536 says:
|
||||||
|
* Configure register GPIO_SWPORTA_DDR and set GPIO as input or output.
|
||||||
|
* When the output pin is configured, write the output value to the
|
||||||
|
* GPIO_SWPORTA_DR register to control the GPIO output level.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define GPIO2 0x03022000
|
||||||
|
#define GPIO_SWPORTA_DR 0x000
|
||||||
|
#define GPIO_SWPORTA_DDR 0x004
|
||||||
|
|
||||||
|
void duo_led_control(int enable);
|
||||||
@ -3,3 +3,4 @@ cvi_mbox-y := rtos_cmdqu.o \
|
|||||||
cvi_spinlock.o
|
cvi_spinlock.o
|
||||||
|
|
||||||
ccflags-y += -I$(srctree)/$(src)/
|
ccflags-y += -I$(srctree)/$(src)/
|
||||||
|
ccflags-$(CONFIG_DYNAMIC_DEBUG) += -DDEBUG
|
||||||
|
|||||||
@ -33,13 +33,6 @@ enum SYSTEM_CMD_TYPE {
|
|||||||
CMDQU_SYSTEM_LIMIT = NR_SYSTEM_CMD,
|
CMDQU_SYSTEM_LIMIT = NR_SYSTEM_CMD,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum SYS_CMD_ID {
|
|
||||||
CMD_TEST_A = 0x10,
|
|
||||||
CMD_TEST_B,
|
|
||||||
CMD_TEST_C,
|
|
||||||
SYS_CMD_INFO_LIMIT,
|
|
||||||
};
|
|
||||||
|
|
||||||
#define RTOS_CMDQU_DEV_NAME "cvi-rtos-cmdqu"
|
#define RTOS_CMDQU_DEV_NAME "cvi-rtos-cmdqu"
|
||||||
#define RTOS_CMDQU_SEND _IOW('r', CMDQU_SEND, unsigned long)
|
#define RTOS_CMDQU_SEND _IOW('r', CMDQU_SEND, unsigned long)
|
||||||
#define RTOS_CMDQU_SEND_WAIT _IOW('r', CMDQU_SEND_WAIT, unsigned long)
|
#define RTOS_CMDQU_SEND_WAIT _IOW('r', CMDQU_SEND_WAIT, unsigned long)
|
||||||
|
|||||||
Reference in New Issue
Block a user