ok
Dependents: Bootcamp-dma-serial
Fork of MODDMA by
Diff: MODDMA.h
- Revision:
- 5:c39b22fa0c60
- Parent:
- 4:67f327b9278e
- Child:
- 6:40d38be4bb59
--- a/MODDMA.h Tue Nov 23 15:33:30 2010 +0000 +++ b/MODDMA.h Tue Nov 23 16:04:32 2010 +0000 @@ -21,7 +21,7 @@ @file MODDMA.h @purpose Adds DMA controller and multiple transfer configurations - @version 1.1 + @version 1.2 @date Nov 2010 @author Andy Kirkham */ @@ -106,7 +106,58 @@ uint32_t srcConn(void) { return SrcConn; } uint32_t dstConn(void) { return DstConn; } uint32_t dmaLLI(void) { return DMALLI; } + + /** + * Attach a callback to the TC IRQ configuration. + * + * @param fptr A function pointer to call + * @return this + */ + class MODDMA_Config * attach_tc(void (*fptr)(void)) { + isrIntTCStat->attach(fptr); + return this; + } + /** + * Attach a callback to the ERR IRQ configuration. + * + * @param fptr A function pointer to call + * @return this + */ + class MODDMA_Config * attach_err(void (*fptr)(void)) { + isrIntErrStat->attach(fptr); + return this; + } + + /** + * Attach a callback to the TC IRQ configuration. + * + * @param tptr A template pointer to the calling object + * @param mptr A method pointer within the object to call. + * @return this + */ + template<typename T> + class MODDMA_Config * attach_tc(T* tptr, void (T::*mptr)(void)) { + if((mptr != NULL) && (tptr != NULL)) { + isrIntTCStat->attach(tptr, mptr); + } + return this; + } + + /** + * Attach a callback to the ERR IRQ configuration. + * + * @param tptr A template pointer to the calling object + * @param mptr A method pointer within the object to call. + * @return this + */ + template<typename T> + class MODDMA_Config * attach_err(T* tptr, void (T::*mptr)(void)) { + if((mptr != NULL) && (tptr != NULL)) { + isrIntErrStat->attach(tptr, mptr); + } + return this; + } FunctionPointer *isrIntTCStat; FunctionPointer *isrIntErrStat; }; @@ -483,11 +534,63 @@ void haltAndWaitChannelComplete(CHANNELS n) { haltChannel(n); while (isActive(n)); } /** + * Attach a callback to the TC IRQ controller. + * + * @ingroup API + * @param fptr A function pointer to call + * @return this + */ + void attach_tc(void (*fptr)(void)) { + isrIntTCStat.attach(fptr); + } + + /** + * Attach a callback to the TC IRQ controller. + * + * @ingroup API + * @param tptr A template pointer to the calling object + * @param mptr A method pointer within the object to call. + * @return this + */ + template<typename T> + class MODDMA_Config * attach_tc(T* tptr, void (T::*mptr)(void)) { + if((mptr != NULL) && (tptr != NULL)) { + isrIntTCStat.attach(tptr, mptr); + } + } + + /** * The MODDMA controllers terminal count interrupt callback. */ FunctionPointer isrIntTCStat; /** + * Attach a callback to the ERR IRQ controller. + * + * @ingroup API + * @param fptr A function pointer to call + * @return this + */ + void attach_err(void (*fptr)(void)) { + isrIntErrStat.attach(fptr); + } + + /** + * Attach a callback to the ERR IRQ controller. + * + * @ingroup API + * @param tptr A template pointer to the calling object + * @param mptr A method pointer within the object to call. + * @return this + */ + template<typename T> + class MODDMA_Config * attach_err(T* tptr, void (T::*mptr)(void)) { + if((mptr != NULL) && (tptr != NULL)) { + isrIntErrStat.attach(tptr, mptr); + } + } + + /** * The MODDMA controllers error interrupt callback. */ FunctionPointer isrIntErrStat;