Exemplo n.º 1
0
void BinarySemaphore::signalI(void) {

    chBSemSignalI(&bsem);
}
Exemplo n.º 2
0
void GADC_ISR_CompleteI(ADCDriver *adcp, adcsample_t *buffer, size_t n) {
	(void) adcp;

	if (curlsdev) {
		/* This interrupt must be in relation to the low speed device */

		if (curlsdev->flags & GADC_FLG_ISACTIVE) {
			/**
			 * As we only handle a single low speed conversion at a time, we know
			 * we know we won't get any half completion interrupts.
			 */
			curlsdev->flags |= GADC_FLG_ISDONE;
			gtimerJabI(&LowSpeedGTimer);
		}

		#if ADC_ISR_FULL_CODE_BUG
			/**
			 * Oops - We have just finished a low speed conversion but a bug prevents us
			 * restarting the ADC here. Other code will restart it in the thread based
			 * ADC handler.
			 */
			gflags &= ~GADC_GFLG_ISACTIVE;
			return;

		#endif

	} else {
		/* This interrupt must be in relation to the high speed device */

		if (hs.flags & GADC_FLG_ISACTIVE) {
			/* Save the details */
			hs.lastcount = n;
			hs.lastbuffer = buffer;
			hs.lastflags = GADC_Timer_Missed ? GADC_HSADC_LOSTEVENT : 0;

			/* Signal the user with the data */
			if (hs.pEvent) {
				#if GFX_USE_GEVENT
					hs.pEvent->type = GEVENT_ADC;
				#endif
				hs.pEvent->count = hs.lastcount;
				hs.pEvent->buffer = hs.lastbuffer;
				hs.pEvent->flags = hs.lastflags;
			}

			/* Our three signalling mechanisms */
			if (hs.isrfn)
				hs.isrfn(buffer, n);

			if (hs.bsem)
				chBSemSignalI(hs.bsem);

			#if GFX_USE_GEVENT
				if (hs.flags & GADC_FLG_GTIMER)
					gtimerJabI(&HighSpeedGTimer);
			#endif

			/* Adjust what we have left to do */
			hs.lld.count -= n;
			hs.remaining -= n;

			/* Half completion - We have done all we can for now - wait for the next interrupt */
			if (hs.lld.count)
				return;

			/* Our buffer is cyclic - set up the new buffer pointers */
			if (hs.remaining) {
				hs.lld.buffer = buffer + (n * hs.samplesPerConversion);
			} else {
				hs.remaining = hs.bufcount;
				hs.lld.buffer = hs.buffer;
			}
			hs.lld.count = hs.remaining < hs.samplesPerEvent ? hs.remaining : hs.samplesPerEvent;
		}
	}

	/**
	 * Look for the next thing to do.
	 */
	FindNextConversionI();
}