示例#1
0
void
pin_change_init(void)
{
        if (PIN_CHANGE_ENABLE(A)) {
                bf_set_reg(SIM_SCGC5, SIM_SCGC5_PORTA, 1);
                PIN_CHANGE_SET_IRQC(A);
                int_enable(IRQ_PORTA);
        }

        if (PIN_CHANGE_ENABLE(B)) {
                bf_set_reg(SIM_SCGC5, SIM_SCGC5_PORTB, 1);
                PIN_CHANGE_SET_IRQC(B);
                int_enable(IRQ_PORTB);
        }

        if (PIN_CHANGE_ENABLE(C)) {
                bf_set_reg(SIM_SCGC5, SIM_SCGC5_PORTC, 1);
                PIN_CHANGE_SET_IRQC(C);
                int_enable(IRQ_PORTC);
        }

        if (PIN_CHANGE_ENABLE(D)) {
                bf_set_reg(SIM_SCGC5, SIM_SCGC5_PORTD, 1);
                PIN_CHANGE_SET_IRQC(D);
                int_enable(IRQ_PORTD);
        }
}
示例#2
0
文件: dma.c 项目: koson/mchck-os
void
main(void)
{
        adc_init();
        dma_init();
        enter_thread_mode();

        sema_wait(&adc_start_sema);

        struct dma_ctx *ctx;
        ctx = dma_setup(DMAMUX_ADC0, &ADC_R_REG(ADC0, 0), dstbuf, 2, sizeof(dstbuf)/2, DMA_SRC_STICKY | DMA_DOUBLEBUF | DMA_LOOP, dma_done, NULL);

        adc_sample_prepare(ADC_MODE_CONTINUOUS);
        bf_set_reg(ADC_SC2_REG(ADC0), ADC_SC2_DMAEN, 1);
        ADC_SC1_REG(ADC0, 0) = ADC_SC1_ADCH(0) | ADC_SC1_DIFF_MASK;

        wait(main);
}