# Tasks
OBJS += task_input.o
OBJS += task_command.o
+OBJS += task_display.o
+OBJS += task_audio.o
+OBJS += task_menu.o
# Kernel
OBJS += kozos.o syscall.o memory.o
# Drivers
OBJS += driver_console.o
OBJS += driver_timer.o
-OBJS += task_display.o
-OBJS += task_audio.o
TARGET = kozos
*/
kz_run(driver_console, "dConsole", 1, 0x200, 0, NULL);
kz_run(driver_timer, "dTimer", 2, 0x200, 0, NULL);
+
/*
* Tasks
*/
- kz_run(task_display, "tDisplay", 5, 0x800, 0, NULL);
kz_run(task_audio, "tAudio", 5, 0x800, 0, NULL);
- kz_run(task_input, "tInput", 5, 0x800, 0, NULL);
- kz_run(task_command, "tCommand", 8, 0x800, 0, NULL);
+ kz_run(task_display, "tDisplay", 6, 0x800, 0, NULL);
+ kz_run(task_menu, "tMenu", 8, 0x800, 0, NULL);
+ kz_run(task_input, "tInput", 8, 0x800, 0, NULL);
+ kz_run(task_command, "tCommand", 9, 0x800, 0, NULL);
kz_chpri(15); /* Í¥Àè½ç°Ì¤ò²¼¤²¤Æ¡¤¥¢¥¤¥É¥ë¥¹¥ì¥Ã¥É¤Ë°Ü¹Ô¤¹¤ë */
INTR_ENABLE; /* ³ä¹þ¤ß͸ú¤Ë¤¹¤ë */
{ 64, 8, NULL },
{ 128, 2, NULL },
{ 256, 2, NULL },
+ { 512, 2, NULL },
{ 1024, 2, NULL },
};
p = &pool[i];
if (size <= p->size - sizeof(kzmem_block)) {
if (p->free == NULL) { /* ²òÊüºÑ¤ßÎΰ褬̵¤¤(¥á¥â¥ê¡¦¥Ö¥í¥Ã¥¯ÉÔÂ) */
- kz_sysdown();
- return NULL;
+ kz_sysdown();
+ return NULL;
}
/* ²òÊüºÑ¤ß¥ê¥ó¥¯¥ê¥¹¥È¤«¤éÎΰè¤ò¼èÆÀ¤¹¤ë */
mp = p->free;
#include "task_command.h"
#include "task_audio.h"
#include "task_display.h"
+#include "task_menu.h"
#endif
#include "vs1011e.h"
#include "kozos.h"
#include "pff.h"
+#include "lib.h"
-#define AUDIO_CMD_PULSE 'p'
+#define AUDIO_CMD_PULSE 'p'
+#define AUDIO_CMD_PLAY 'd'
void audio_pulse(void)
{
kz_send(MSGBOX_ID_AUDIO, 1, p);
}
+void audio_play(void *buf, int siz)
+{
+ char *p;
+ p = kz_kmalloc(4 + siz);
+ p[0] = AUDIO_CMD_PLAY;
+ p[1] = 0;
+ p[2] = (siz >> 8) & 0xff;
+ p[3] = (siz >> 0) & 0xff;
+ memcpy((void *)&p[4], buf, siz);
+ kz_send(MSGBOX_ID_AUDIO, 4 + siz, p);
+}
+
static int audio_cmdproc(char *p)
{
int cmd = p[0];
vs1011e_sinetest_fini();
for (i = 0; i < 1000; i++) { }
break;
+ case AUDIO_CMD_PLAY:
+ puts(">");
+ vs1011e_play_with_data(
+ &p[4],
+ ((unsigned char)p[2] << 8) | ((unsigned char)p[3] << 0));
+ break;
default:
break;
}
return 0;
}
-int readfunc(void * buf, const int len)
-{
- WORD cnt;
- pf_read(buf, len, &cnt);
- kz_wait();
- return cnt;
-}
-
-static int play(const char *filename)
-{
- FRESULT r = pf_open("splash.mp3");
- if (r != FR_OK) {
- return 1;
- }
- int siz = 512;
- void *p = kz_kmalloc(siz);
- vs1011e_play(p, siz, readfunc);
- kz_kmfree(p);
- return 0;
-}
-
int task_audio(int argc, char *argv[])
{
int size;
char *p;
-#if 0
- /*
- * mp3\e$B%U%!%$%k$N:F@8%F%9%H!#\e(B
- */
- FATFS fatfs;
- DIR dir;
- FILINFO filinfo;
-
- vs1011e_volume_write(0x02, 0x02);
- 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 (play(filinfo.fname)) {
- break;
- }
- }
- }
- }
- }
-#endif
-
while (1) {
kz_recv(MSGBOX_ID_AUDIO, &size, &p);
audio_cmdproc(p);
#define TASK_AUDIO_H
void audio_pulse(void);
+void audio_play(void *buf, int siz);
int task_audio(int argc, char *argv[]);
#endif
--- /dev/null
+
+#include "task_menu.h"
+#include "task_audio.h"
+#include "pff.h"
+#include "kozos.h"
+#include "lib.h"
+
+static int play(const char *filename)
+{
+ FRESULT r = pf_open("splash.mp3");
+ if (r != FR_OK) {
+ return 1;
+ }
+ WORD cnt;
+ const int siz = 32;
+ do {
+ puts("o");
+ void *buf = kz_kmalloc(siz);
+ pf_read(buf, siz, &cnt);
+ audio_play(buf, cnt);
+ } while (cnt == siz);
+ return 0;
+}
+
+int task_menu(int argc, char *argv[])
+{
+#if 0
+ FATFS fatfs;
+ DIR dir;
+ FILINFO filinfo;
+
+ 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 (play(filinfo.fname)) {
+ break;
+ }
+ }
+ }
+ }
+ }
+#else
+ while (1) {
+ kz_wait();
+ }
+#endif
+
+ return 0;
+}
+
--- /dev/null
+
+#ifndef _TASK_MENU_H_
+#define _TASK_MENU_H_
+
+int task_menu(int argc, char *argv[]);
+
+#endif
+
#include "vs1011e.h"
#include "portconf.h"
#include "spi.h"
-#include "kozos.h"
#define VS1011E_OPCODE_READ 0x03
#define VS1011E_OPCODE_WRITE 0x02
void vs1011e_play(
void *buf, int siz,
+ int (*waitfunc)(void),
int (*readfunc)(void * buf, const int len))
{
int i;
spi_select(SpiTarget_VS1011E_DATA);
for (i = 0; i < n; i++) {
while (VS1011E_CHK_DREQ()) {
- kz_wait();
+ if (waitfunc() <= 0) {
+ return;
+ }
}
spi_tx(*((char *)buf + i));
}
}
}
+void vs1011e_play_with_data(void *buf, int siz)
+{
+ int i;
+ /*
+ * Send the data.
+ */
+ spi_select(SpiTarget_VS1011E_DATA);
+ for (i = 0; i < siz; i++) {
+ while (VS1011E_CHK_DREQ()) {
+ }
+ spi_tx(*((char *)buf + i));
+ }
+ spi_deselect();
+}
+
void vs1011e_decodetime_read(uint16 * sec)
{
vs1011e_read(REGADDR_DECODE_TIME, sec);
void vs1011e_volume_write(const uint8 left, const uint8 right);
void vs1011e_play(
void *buf, int siz,
+ int (*waitfunc)(void),
int (*readfunc)(void * buf, const int len));
+void vs1011e_play_with_data(void *buf, int siz);
void vs1011e_decodetime_read(uint16 * sec);
void vs1011e_decodetime_write(const uint16 sec);
void vs1011e_register_print(void);