23 lines
475 B
C
23 lines
475 B
C
#include "ring.h"
|
|
|
|
#include <STRING.H>
|
|
|
|
S_ADC_RING xdata adcRing;
|
|
|
|
void InitRing(S_ADC_RING *ring) {
|
|
ring->index = 0;
|
|
// ring->max = 0;
|
|
// ring->min = 1024;
|
|
ring->full = FALSE;
|
|
memset(ring->buf, 0, sizeof(ring->buf));
|
|
}
|
|
|
|
void SaveRing(S_ADC_RING *ring, u16 val) {
|
|
// 保存数值
|
|
ring->buf[ring->index] = val;
|
|
// 循环队列前进
|
|
ring->index = ++ring->index % ADC_BUF_LENGTH;
|
|
if (ring->index == 0) {
|
|
if (!ring->full) ring->full = TRUE;
|
|
}
|
|
} |