📄 hellotimer.c
字号:
/* * dspapps/dsp/task_testB/hellotimer.c * * Example of DSP task which uses Timer Queue * * Copyright (C) 2002,2003 Nokia Corporation * * Written by Toshihiro Kobayashi <toshihiro.kobayashi@nokia.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * $Id: hellotimer.c * $Revision: 2.0 * $Date: 2003/11/11 * */#include <std.h>#include <sys.h>#include <mem.h>#include "mailbox.h"#include "tokliBIOS.h"Int strcpy16to8(Char *d, Char *s);static Uns ht_rcv_wdsnd(struct dsptask *task, Uns data);static Uns ht_callback(struct dsptask *task);struct task_ht { struct dsptask task_head; Int cnt; Void *t1q_id;};struct task_ht task_hellotimer = { { TID_MAGIC, // tid "hellotimer", // name MBCMD_TTYP_BKDM | MBCMD_TTYP_ASND, // ttyp: active block snd, passive word rcv ht_rcv_wdsnd, // rcv_snd NULL, // rcv_req NULL, // rcv_tctl NULL // tsk_attrs },};Int strcpy16to8(Char *d, Char *s){ Int cnt = 0; for(; *s; s++, d++) { *d = *s; *d |= *++s << 8; cnt++; if(!*s) return cnt; } *d = '\0'; return cnt;}static Uns ht_rcv_wdsnd(struct dsptask *task, Uns data){ struct task_ht *task_ht = (struct task_ht*)task; void *qid; task_ht->cnt = data; qid = register_tq_1s(task, ht_callback); if(qid == MEM_ILLEGAL) return MBCMD_EID_NORES; task_ht->t1q_id = qid; return 0;}static Uns ht_callback(struct dsptask *task){ struct task_ht *task_ht = (struct task_ht*)task; Uns bid; Int cnt; Char s[100]; SYS_sprintf(s, "ht_callback(): task_ht->cnt = %d\n", task_ht->cnt); dbg(task, s); bid = get_free_ipbuf(task); if(bid == MBCMD_BID_NULL) return MBCMD_EID_STVBUF; cnt = strcpy16to8((Char*)ipbuf_d[bid], "Hello from DSP!\n"); bksnd(task, bid, cnt); task_ht->cnt--; if(task_ht->cnt == 0) { unregister_tq_1s(task, task_ht->t1q_id); } return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -