OBJS += spi.o spreg.o
# Tasks
-OBJS += task_input.o
-OBJS += task_command.o
-OBJS += task_display.o
OBJS += task_audio.o
+OBJS += task_display.o
+OBJS += task_fileio.o
OBJS += task_system.o
+OBJS += task_input.o
+OBJS += task_command.o
# Kernel
OBJS += kozos.o syscall.o memory.o
extern kz_thread_id_t tskid_audio;
extern kz_thread_id_t tskid_display;
+extern kz_thread_id_t tskid_fileio;
extern kz_thread_id_t tskid_system;
extern kz_thread_id_t tskid_input;
extern kz_thread_id_t tskid_command;
kz_thread_id_t tskid_audio;
kz_thread_id_t tskid_display;
+kz_thread_id_t tskid_fileio;
kz_thread_id_t tskid_system;
kz_thread_id_t tskid_input;
kz_thread_id_t tskid_command;
tskid_system = kz_run(task_system, "tSystem", 5, 0x800, 0, NULL);
tskid_input = kz_run(task_input, "tInput", 6, 0x800, 0, NULL);
tskid_command = kz_run(task_command, "tCommand", 7, 0x800, 0, NULL);
+ tskid_fileio = kz_run(task_fileio, "tFileIO", 8, 0x800, 0, NULL);
kz_chpri(15); /* Í¥Àè½ç°Ì¤ò²¼¤²¤Æ¡¤¥¢¥¤¥É¥ë¥¹¥ì¥Ã¥É¤Ë°Ü¹Ô¤¹¤ë */
INTR_ENABLE; /* ³ä¹þ¤ß͸ú¤Ë¤¹¤ë */
#ifndef TASK_H
#define TASK_H
-#include "task_input.h"
-#include "task_command.h"
#include "task_audio.h"
#include "task_display.h"
+#include "task_fileio.h"
#include "task_system.h"
+#include "task_input.h"
+#include "task_command.h"
#endif
--- /dev/null
+#include "defines.h"
+#include "kozos.h"
+#include "lib.h"
+#include "intr.h"
+#include "portconf.h"
+#include "pff.h"
+
+#define VS1011E_CHK_DREQ() (((*PORTCONF_P4DR) & PORTCONF_P4BIT_VSDREQ) ? 0 : 1)
+
+static FATFS fatfs;
+static DIR dir;
+static FILINFO filinfo;
+
+static int readfunc(void *buf, int siz)
+{
+ WORD cnt;
+ pf_read(buf, siz, &cnt);
+ return cnt;
+}
+
+static int play(const char *filename)
+{
+ FRESULT r = pf_open(filename);
+ if (r != FR_OK) {
+ return 1;
+ }
+ while (audio_play(readfunc)) {
+ while (VS1011E_CHK_DREQ()) {
+ kz_wait();
+ }
+ }
+ return 0;
+}
+
+static int is_music_file(const char *filename)
+{
+ int len = strlen(filename);
+ if (len < 4) {
+ return 0;
+ }
+ if (strcmp(filename + len - 4, ".MP3") == 0) {
+ return 1;
+ }
+ if (strcmp(filename + len - 4, ".WAV") == 0) {
+ return 1;
+ }
+ return 0;
+}
+
+int task_fileio(int argc, char *argv[])
+{
+ while (1) {
+ if (pf_mount(&fatfs)) {
+ continue;
+ }
+ while (1) {
+ if (pf_opendir(&dir, "")) {
+ break;
+ }
+ while (!pf_readdir(&dir, &filinfo) && filinfo.fname[0]) {
+ if (!(filinfo.fattrib & (AM_DIR | AM_HID))) {
+ if (is_music_file(filinfo.fname)) {
+ display_draw_text(40, 4, filinfo.fname);
+ if (play(filinfo.fname)) {
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return 0;
+}
+
--- /dev/null
+
+#ifndef TASK_FILEIO_H
+#define TASK_FILEIO_H
+
+int task_fileio(int argc, char *argv[]);
+
+#endif
#include "re.h"
#include "intr.h"
#include "portconf.h"
-#include "pff.h"
#define H8_3069F_ISCR ((volatile uint8 *)0xFEE014)
#define H8_3069F_IER ((volatile uint8 *)0xFEE015)
static uint8 data[MAX_BIT_COUNT / 8];
static uint16 bitcnt = 0;
static uint16 prev = 0, curr = 0;
-static FATFS fatfs;
-static DIR dir;
-static FILINFO filinfo;
static void remocon_intr_edge(void)
{
}
}
-static int readfunc(void *buf, int siz)
-{
- WORD cnt;
- pf_read(buf, siz, &cnt);
- return cnt;
-}
-
-static int play(const char *filename)
-{
- FRESULT r = pf_open(filename);
- if (r != FR_OK) {
- return 1;
- }
- while (audio_play(readfunc)) {
- }
- return 0;
-}
-
-static int is_music_file(const char *filename)
-{
- int len = strlen(filename);
- if (len < 4) {
- return 0;
- }
- if (strcmp(filename + len - 4, ".MP3") == 0) {
- return 1;
- }
- if (strcmp(filename + len - 4, ".WAV") == 0) {
- return 1;
- }
- return 0;
-}
-
int task_input(int argc, char *argv[])
{
/*
audio_volume(250, 250);
while (1) {
- if (pf_mount(&fatfs)) {
- continue;
- }
- while (1) {
- if (pf_opendir(&dir, "")) {
- break;
- }
- while (!pf_readdir(&dir, &filinfo) && filinfo.fname[0]) {
- if (!(filinfo.fattrib & (AM_DIR | AM_HID))) {
- if (is_music_file(filinfo.fname)) {
- display_draw_text(40, 4, filinfo.fname);
- if (play(filinfo.fname)) {
- break;
- }
- }
- }
- }
- }
+ kz_sleep();
}
return 0;