[an error occurred while processing this directive]
|
хотелось бы определить с самого начала "правильный" стиль, чтоб потом двадцать раз не дергаться назад, т.е. чтобы потом она выглядела как и полагается нормальным программам, легко модифицируемая, понятная другим и прочее, а не выкидышь, где например через строчку напрямую пишутся адреса, вместо того чтобы определить Define/ (это так к слову). [к ANSI не посылать]
под стилем [касательно DSP] подразумеваю в основном использование DSP/BIOS (не очень то понял накой он нужен), библиотек CSL.
Распространено ли это ??
ниже приведен пример из CCS. Это большенство программ так выглядят или же использование настолько загроможденных структур (на мой взгляд) излишне, ведь вообщем можно здесь всего несколькими строчками обойтись ??
include #include /*----------------------------------------------------------------------------*/ /* Reference to start of interrupt vectors */ TIMER_Handle mhTimer; /*----------------------------------------------------------------------------*/ /* Initialize CSL library, this step is required */ /* Call example task function */ /*----------------------------------------------------------------------------*/ Uint16 eventId; printf(" /* Temporarily disable all maskable interrupts, preserving */ /* Open Timer 0, this returns a pointer to a Timer Handle */ /* Clear any pending Timer interrupts */ /* Place event ID in interrupt map for dispatcher */ /* Enable Timer interrupt */ /* Enable all maskable interrupts */ /* Start Timer */ /* wait for 20 timer periods */ /* We are through with the Timer, so close it */ /* Restore previous state of INTM */ printf("%s\n",err?"Timer example FAILED":"Timer example PASSED"); /*----------------------------------------------------------------------------*/ /* Timer ISR - will be called by DSP/BIOS dispatcher */
E-mail:
info@telesys.ru
#include
#include
/* In this exmaple, we are simply setting the timer to interrupt */
/* every 0x800 clock cycles. All timer setup will be done in a */
/* TSK function that executes after exit from "main" */
/* Create a timer control structure */
TIMER_Config myTConfig = {
TIMER_TCR_RMK(
TIMER_TCR_SOFT_WAITZERO,
TIMER_TCR_FREE_NOSOFT,
TIMER_TCR_TRB_RESET,
TIMER_TCR_TSS_START,
TIMER_TCR_TDDR_OF(0)
), /* TCR0 */
0x0800u /* PRD0 */
};
/* Global declarations */
extern void VECSTART(void);
volatile Uint16 timer_int_cnt = 0;
interrupt void timerIsr(void);
void taskFunc(void);
void main() {
CSL_init();
/* Initialize IPTR */
IRQ_setVecs((Uint16)(&VECSTART));
taskFunc();
}
void taskFunc(void) {
int old_intm;
Uint16 err = 0;
/* previous state of INTM */
old_intm = IRQ_globalDisable();
/* that will be used as an argument to other CSL functions */
mhTimer = TIMER_open(TIMER_DEV0, TIMER_OPEN_RESET);
/* Write configuration structure values to Timer control */
/* registers. */
TIMER_config(mhTimer, &myTConfig);
/* Get Event ID associated with Timer interrupt */
eventId = TIMER_getEventId(mhTimer);
IRQ_clear(eventId);
IRQ_plug(eventId,timerIsr);
IRQ_enable(eventId);
IRQ_globalEnable();
TIMER_start(mhTimer);
while(timer_int_cnt < 20);
TIMER_close(mhTimer);
IRQ_globalRestore(old_intm);
if (timer_int_cnt < 20)
++err;
printf("
}
interrupt void timerIsr(void) {
TIMER_stop(mhTimer);
++timer_int_cnt;
TIMER_start(mhTimer);
}
Ответы