| 55 | } |
| 56 | |
| 57 | static rt_err_t CME_M7_control(struct rt_serial_device *serial, int cmd, void *arg) |
| 58 | { |
| 59 | struct CME_M7_uart* uart; |
| 60 | NVIC_InitTypeDef NVIC_InitStructure; |
| 61 | |
| 62 | RT_ASSERT(serial != RT_NULL); |
| 63 | uart = (struct CME_M7_uart *)serial->parent.user_data; |
| 64 | |
| 65 | switch (cmd) |
| 66 | { |
| 67 | case RT_DEVICE_CTRL_CLR_INT: |
| 68 | /* disable rx irq */ |
| 69 | NVIC_InitStructure.NVIC_IRQChannel = uart->irq; |
| 70 | NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; |
| 71 | NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; |
| 72 | NVIC_InitStructure.NVIC_IRQChannelCmd = FALSE; |
| 73 | NVIC_Init(&NVIC_InitStructure); |
| 74 | |
| 75 | UART_EnableInt(uart->uart_device, UART_Int_RxNotEmpty, FALSE); |
| 76 | break; |
| 77 | |
| 78 | case RT_DEVICE_CTRL_SET_INT: |
| 79 | /* enable rx irq */ |
| 80 | NVIC_InitStructure.NVIC_IRQChannel = uart->irq; |
| 81 | NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; |
| 82 | NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; |
| 83 | NVIC_InitStructure.NVIC_IRQChannelCmd = TRUE; |
| 84 | NVIC_Init(&NVIC_InitStructure); |
| 85 | |
| 86 | UART_ClearInt(uart->uart_device, UART_Int_RxNotEmpty); |
| 87 | UART_EnableInt(uart->uart_device, UART_Int_RxNotEmpty, TRUE); |
| 88 | break; |
| 89 | } |
| 90 | |
| 91 | return RT_EOK; |
| 92 | } |
| 93 | |
| 94 | static int CME_M7_putc(struct rt_serial_device *serial, char ch) |
| 95 | { |
nothing calls this directly
no test coverage detected