-
Notifications
You must be signed in to change notification settings - Fork 5
Univ ldma handler dev #68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
41697a7
10a7079
61b1d25
d03c204
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| #ifndef LDMA_HANDLER_CONF | ||
| #define LDMA_HANDLER_CONF | ||
|
|
||
| #include "cmsis_os2.h" | ||
|
|
||
| typedef struct { | ||
| uint32_t channel; | ||
| osThreadId_t thrd; | ||
| uint32_t name; | ||
| uint32_t signal; | ||
| struct ldma_handler_conf_t* next; | ||
| } ldma_handler_conf_t; | ||
|
|
||
| void append_to_ldma_stored_configuration(ldma_handler_conf_t * newconf); | ||
|
|
||
| #endif //LDMA_HANDLER_CONF |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
|
|
||
| #include "platform.h" | ||
| #include "em_device.h" | ||
| #include "em_gpio.h" | ||
| #include "em_cmu.h" | ||
| #include "ldma_handler.h" | ||
| #include "em_ldma.h" | ||
| #include "cmsis_os2.h" | ||
| #include "sys_panic.h" | ||
|
|
||
| #define SIZE_OF_ARRAY(arr) (sizeof(arr))/sizeof(arr[0]) | ||
|
|
||
| static volatile ldma_handler_conf_t m_head = {0xFF, NULL, 0, 0, NULL}; | ||
|
|
||
|
|
||
| void LDMA_IRQHandler (void) | ||
| { | ||
| uint32_t pending = LDMA_IntGet(); | ||
|
|
||
| while (pending & LDMA_IF_ERROR) | ||
| { | ||
| //err1("ldma if"); | ||
| } | ||
|
|
||
|
|
||
|
|
||
| ldma_handler_conf_t* ptr = &m_head; | ||
| while(ptr != NULL) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. BARR - add space |
||
| { | ||
| if ( pending & (1 << ptr->channel) ) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. BARR - remove spaces if ((pending & (1 << ptr->channel))) |
||
| { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Identation - open all files in editor and convert tabs to spaces and check after that the indentation is correct |
||
| osThreadFlagsSet(ptr->thrd, ptr->signal); | ||
| } | ||
| ptr = ptr->next; | ||
| } | ||
| LDMA_IntClear(pending); | ||
| } | ||
|
|
||
| void append_to_ldma_stored_configuration(ldma_handler_conf_t * newconf) | ||
| { | ||
| //append to configuration | ||
| ldma_handler_conf_t *ptr = &m_head; | ||
| if(!m_head.next) | ||
| { | ||
| // adding first config | ||
| ptr->next = newconf; | ||
| } | ||
| else | ||
| { | ||
| //looping to the end of list | ||
| while(ptr != NULL && ptr->next != NULL) | ||
| { | ||
| ptr = ptr->next; | ||
| } | ||
| //adding new element | ||
| ptr->next = newconf; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,6 +27,7 @@ | |
| #include "dmadrv.h" | ||
| #else | ||
| #include "em_ldma.h" | ||
| #include "ldma_handler.h" | ||
| #endif//LOGGER_LDMA_DMADRV | ||
|
|
||
| #include "sleep.h" | ||
|
|
@@ -60,6 +61,7 @@ static osThreadId_t m_ldma_thread; | |
| static osMutexId_t m_log_mutex; | ||
| static bool m_ldma_idle; | ||
| static bool m_uart_active; | ||
| static ldma_handler_conf_t m_ldma_handler_conf; | ||
|
|
||
| static unsigned int m_dma_channel = LOGGER_LDMA_CHANNEL; | ||
|
|
||
|
|
@@ -68,13 +70,15 @@ static unsigned int m_dma_channel = LOGGER_LDMA_CHANNEL; | |
| static bool dmadrv_callback (unsigned int channel, unsigned int sequenceNo, void * data) | ||
| { | ||
| osThreadFlagsSet(m_ldma_thread, LOGGER_THREAD_FLAG_LDMA_DONE); | ||
| //PLATFORM_LedsSet(PLATFORM_LedsGet()^1); | ||
| return false; | ||
| } | ||
| #else | ||
| /* | ||
| void LDMA_IRQHandler (void) | ||
| { | ||
| uint32_t pending = LDMA_IntGet(); | ||
|
|
||
| PLATFORM_LedsSet(PLATFORM_LedsGet()^1); | ||
| while (pending & LDMA_IF_ERROR) | ||
| { | ||
| sys_panic("ldma if"); | ||
|
|
@@ -87,6 +91,7 @@ void LDMA_IRQHandler (void) | |
| osThreadFlagsSet(m_ldma_thread, LOGGER_THREAD_FLAG_LDMA_DONE); | ||
| } | ||
| } | ||
| */ | ||
| #endif//LOGGER_LDMA_DMADRV | ||
|
|
||
|
|
||
|
|
@@ -225,13 +230,15 @@ static void ldma_thread (void* argument) | |
|
|
||
| while (osOK != osMutexAcquire(m_log_mutex, osWaitForever)); | ||
|
|
||
| if (flags & LOGGER_THREAD_FLAG_LDMA_DONE) | ||
| if (flags & LOGGER_THREAD_FLAG_LDMA_DONE ) | ||
| { | ||
|
|
||
| busy = false; | ||
| m_buf_full = false; | ||
| m_buf_start = m_buf_pos; | ||
| } | ||
|
|
||
|
|
||
| if ((m_buf_start >= LOGGER_LDMA_BUFFER_LENGTH)||(m_buf_end >= LOGGER_LDMA_BUFFER_LENGTH)) | ||
| { | ||
| sys_panic("ldma buf"); | ||
|
|
@@ -262,6 +269,14 @@ int logger_ldma_init () | |
| return 1; // should perhaps panic instead | ||
| } | ||
| #else | ||
|
|
||
|
|
||
| m_ldma_handler_conf.channel = LOGGER_LDMA_CHANNEL; | ||
| m_ldma_handler_conf.signal = LOGGER_THREAD_FLAG_LDMA_DONE; | ||
| m_ldma_handler_conf.thrd = m_ldma_thread; | ||
| m_ldma_handler_conf.name = 69; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use constants instead of mystical numbers. e.g. #define DEFAULT_CONF_NAME 69 |
||
| m_ldma_handler_conf.next = NULL; | ||
| append_to_ldma_stored_configuration(&m_ldma_handler_conf); | ||
| LDMA_Init_t initLdma = LDMA_INIT_DEFAULT; | ||
| initLdma.ldmaInitIrqPriority = LDMA_INTERRUPT_PRIORITY; | ||
| LDMA_Init(&initLdma); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use structre members names to initialize them e.g. const osThreadAttr_t app_thread_attr = { .name = "app" };