ZNeo Serial: Need to configure UART1 alternate function
This commit is contained in:
parent
344ed99bd4
commit
07bc8e53ff
@ -148,8 +148,8 @@
|
|||||||
_z16f_reset:
|
_z16f_reset:
|
||||||
/* Initialize the init/idle task stack */
|
/* Initialize the init/idle task stack */
|
||||||
|
|
||||||
ld sp, #(_near_stack+1) /* Set Stack Pointer to the top of internal RAM */
|
ld sp, #(_near_stack+1) /* Set Stack Pointer to the top of internal RAM */
|
||||||
clr fp
|
clr fp
|
||||||
|
|
||||||
/* Initialize clocking */
|
/* Initialize clocking */
|
||||||
|
|
||||||
@ -163,27 +163,27 @@ _z16f_reset:
|
|||||||
/* Perform VERY early UART initialization so that we can use it here */
|
/* Perform VERY early UART initialization so that we can use it here */
|
||||||
|
|
||||||
#ifdef USE_LOWUARTINIT
|
#ifdef USE_LOWUARTINIT
|
||||||
call _z16f_lowuartinit /* Initialize the UART for debugging */
|
call _z16f_lowuartinit /* Initialize the UART for debugging */
|
||||||
#endif
|
#endif
|
||||||
/* Initialize the hardware stack overflow register */
|
/* Initialize the hardware stack overflow register */
|
||||||
|
|
||||||
#ifdef CONFIG_Z16F_INITSPOV
|
#ifdef CONFIG_Z16F_INITSPOV
|
||||||
ld r0, #(_near_stack_bot+1)
|
ld r0, #(_near_stack_bot+1)
|
||||||
ld spov, r0
|
ld spov, r0
|
||||||
#endif
|
#endif
|
||||||
/* Clear BSS */
|
/* Clear BSS */
|
||||||
|
|
||||||
lea r0, _low_nearbss
|
lea r0, _low_nearbss
|
||||||
ld r1, #_len_nearbss+1
|
ld r1, #_len_nearbss+1
|
||||||
jp _z16f_reset2
|
jp _z16f_reset2
|
||||||
_z16f_reset1:
|
_z16f_reset1:
|
||||||
ld.b (r0++), #0
|
ld.b (r0++), #0
|
||||||
_z16f_reset2:
|
_z16f_reset2:
|
||||||
djnz r1, _z16f_reset1
|
djnz r1, _z16f_reset1
|
||||||
|
|
||||||
lea r0, _low_farbss
|
lea r0, _low_farbss
|
||||||
ld r1, #_len_farbss+1
|
ld r1, #_len_farbss+1
|
||||||
jp _z16f_reset4
|
jp _z16f_reset4
|
||||||
_z16f_reset3:
|
_z16f_reset3:
|
||||||
ld.b (r0++), #0
|
ld.b (r0++), #0
|
||||||
_z16f_reset4:
|
_z16f_reset4:
|
||||||
@ -191,20 +191,20 @@ _z16f_reset4:
|
|||||||
|
|
||||||
/* Copy ROM data into RAM */
|
/* Copy ROM data into RAM */
|
||||||
|
|
||||||
lea r0, _low_near_romdata
|
lea r0, _low_near_romdata
|
||||||
lea r1, _low_neardata
|
lea r1, _low_neardata
|
||||||
ld r2, #_len_neardata+1
|
ld r2, #_len_neardata+1
|
||||||
jp _z16f_reset6
|
jp _z16f_reset6
|
||||||
_z16f_reset5:
|
_z16f_reset5:
|
||||||
ld.b r3, (r0++)
|
ld.b r3, (r0++)
|
||||||
ld.b (r1++), r3
|
ld.b (r1++), r3
|
||||||
_z16f_reset6:
|
_z16f_reset6:
|
||||||
djnz r2, _z16f_reset5
|
djnz r2, _z16f_reset5
|
||||||
|
|
||||||
lea r0, _low_far_romdata
|
lea r0, _low_far_romdata
|
||||||
lea r1, _low_fardata
|
lea r1, _low_fardata
|
||||||
ld r2, #_len_fardata+1
|
ld r2, #_len_fardata+1
|
||||||
jp _z16f_reset8
|
jp _z16f_reset8
|
||||||
_z16f_reset7:
|
_z16f_reset7:
|
||||||
ld.b r3, (r0++)
|
ld.b r3, (r0++)
|
||||||
ld.b (r1++), r3
|
ld.b (r1++), r3
|
||||||
@ -213,7 +213,7 @@ _z16f_reset8:
|
|||||||
|
|
||||||
/* Perform low-level hardware initialization */
|
/* Perform low-level hardware initialization */
|
||||||
|
|
||||||
call _z16f_lowinit /* Perform low-level hardware initialization */
|
call _z16f_lowinit /* Perform low-level hardware initialization */
|
||||||
|
|
||||||
#ifdef USE_EARLYSERIALINIT
|
#ifdef USE_EARLYSERIALINIT
|
||||||
/* Perform early serial initialization */
|
/* Perform early serial initialization */
|
||||||
@ -222,8 +222,8 @@ _z16f_reset8:
|
|||||||
#endif
|
#endif
|
||||||
/* Start NuttX */
|
/* Start NuttX */
|
||||||
|
|
||||||
call _os_start /* Start the operating system */
|
call _os_start /* Start the operating system */
|
||||||
_halt1: /* _os_start() should not return */
|
_halt1: /* _os_start() should not return */
|
||||||
halt
|
halt
|
||||||
jp _halt1
|
jp _halt1
|
||||||
|
|
||||||
@ -244,15 +244,15 @@ _halt1: /* _os_start() should not return */
|
|||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
_sysexc_isr:
|
_sysexc_isr:
|
||||||
pushmlo <r0-r7> /* Save r0-r7 on the stack */
|
pushmlo <r0-r7> /* Save r0-r7 on the stack */
|
||||||
|
|
||||||
/* Calculate the value of the SP BEFORE the interrupt occurred and
|
/* Calculate the value of the SP BEFORE the interrupt occurred and
|
||||||
* push that as the saved value of r15=sp
|
* push that as the saved value of r15=sp
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ld r1, #-6 /* return(4) + flags(1) + padding(1) */
|
ld r1, #-6 /* return(4) + flags(1) + padding(1) */
|
||||||
add r1, sp /* r1 = Value of the SP before the interrupt */
|
add r1, sp /* r1 = Value of the SP before the interrupt */
|
||||||
push r1 /* Push r1 in the spot for the saved SP */
|
push r1 /* Push r1 in the spot for the saved SP */
|
||||||
|
|
||||||
/* Save all of the remaining registers */
|
/* Save all of the remaining registers */
|
||||||
|
|
||||||
@ -263,10 +263,10 @@ _sysexc_isr:
|
|||||||
* of the register save structure.
|
* of the register save structure.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ld r1, sp
|
ld r1, sp
|
||||||
call _z16f_sysexec /* Handle in C logic */
|
call _z16f_sysexec /* Handle in C logic */
|
||||||
|
|
||||||
_halt2: /* _z16f_sysexec() should not return */
|
_halt2: /* _z16f_sysexec() should not return */
|
||||||
halt
|
halt
|
||||||
jp _halt2
|
jp _halt2
|
||||||
|
|
||||||
@ -287,125 +287,124 @@ _halt2: /* _z16f_sysexec() should not return */
|
|||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
_timer2_isr:
|
_timer2_isr:
|
||||||
pushmlo <r0-r7> /* Save r0-r7 on the stack */
|
pushmlo <r0-r7> /* Save r0-r7 on the stack */
|
||||||
ld r1, #Z16F_IRQ_TIMER2 /* r1 = Timer 2 IRQ number */
|
ld r1, #Z16F_IRQ_TIMER2 /* r1 = Timer 2 IRQ number */
|
||||||
jp _common_isr /* Join common interrupt handling logic */
|
jp _common_isr /* Join common interrupt handling logic */
|
||||||
|
|
||||||
_timer1_isr:
|
_timer1_isr:
|
||||||
pushmlo <r0-r7> /* Save r0-r7 on the stack */
|
pushmlo <r0-r7> /* Save r0-r7 on the stack */
|
||||||
ld r1, #Z16F_IRQ_TIMER1 /* r1 = Timer 1 IRQ number */
|
ld r1, #Z16F_IRQ_TIMER1 /* r1 = Timer 1 IRQ number */
|
||||||
jp _common_isr /* Join common interrupt handling logic */
|
jp _common_isr /* Join common interrupt handling logic */
|
||||||
|
|
||||||
_timer0_isr:
|
_timer0_isr:
|
||||||
pushmlo <r0-r7> /* Save r0-r7 on the stack */
|
pushmlo <r0-r7> /* Save r0-r7 on the stack */
|
||||||
ld r1, #Z16F_IRQ_TIMER0 /* r1 = Timer 0 IRQ number */
|
ld r1, #Z16F_IRQ_TIMER0 /* r1 = Timer 0 IRQ number */
|
||||||
jp _common_isr /* Join common interrupt handling logic */
|
jp _common_isr /* Join common interrupt handling logic */
|
||||||
|
|
||||||
_uart0rx_isr:
|
_uart0rx_isr:
|
||||||
pushmlo <r0-r7> /* Save r0-r7 on the stack */
|
pushmlo <r0-r7> /* Save r0-r7 on the stack */
|
||||||
ld r1, #Z16F_IRQ_UART0RX /* r1 = UART0 RX IRQ number */
|
ld r1, #Z16F_IRQ_UART0RX /* r1 = UART0 RX IRQ number */
|
||||||
jp _common_isr /* Join common interrupt handling logic */
|
jp _common_isr /* Join common interrupt handling logic */
|
||||||
|
|
||||||
_uart0tx_isr:
|
_uart0tx_isr:
|
||||||
pushmlo <r0-r7> /* Save r0-r7 on the stack */
|
pushmlo <r0-r7> /* Save r0-r7 on the stack */
|
||||||
ld r1, #Z16F_IRQ_UART0TX /* r1 = UART0 TX IRQ number */
|
ld r1, #Z16F_IRQ_UART0TX /* r1 = UART0 TX IRQ number */
|
||||||
jp _common_isr /* Join common interrupt handling logic */
|
jp _common_isr /* Join common interrupt handling logic */
|
||||||
|
|
||||||
_i2c_isr:
|
_i2c_isr:
|
||||||
pushmlo <r0-r7> /* Save r0-r7 on the stack */
|
pushmlo <r0-r7> /* Save r0-r7 on the stack */
|
||||||
ld r1, #Z16F_IRQ_I2C /* r1 = I2C IRQ number */
|
ld r1, #Z16F_IRQ_I2C /* r1 = I2C IRQ number */
|
||||||
jp _common_isr /* Join common interrupt handling logic */
|
jp _common_isr /* Join common interrupt handling logic */
|
||||||
|
|
||||||
_spi_isr:
|
_spi_isr:
|
||||||
pushmlo <r0-r7> /* Save r0-r7 on the stack */
|
pushmlo <r0-r7> /* Save r0-r7 on the stack */
|
||||||
ld r1, #Z16F_IRQ_SPI /* r1 = SPI IRQ number */
|
ld r1, #Z16F_IRQ_SPI /* r1 = SPI IRQ number */
|
||||||
jp _common_isr /* Join common interrupt handling logic */
|
jp _common_isr /* Join common interrupt handling logic */
|
||||||
|
|
||||||
_adc_isr:
|
_adc_isr:
|
||||||
pushmlo <r0-r7> /* Save r0-r7 on the stack */
|
pushmlo <r0-r7> /* Save r0-r7 on the stack */
|
||||||
ld r1, #Z16F_IRQ_ADC /* r1 = ADC IRQ number */
|
ld r1, #Z16F_IRQ_ADC /* r1 = ADC IRQ number */
|
||||||
jp _common_isr /* Join common interrupt handling logic */
|
jp _common_isr /* Join common interrupt handling logic */
|
||||||
|
|
||||||
_p7ad_isr:
|
_p7ad_isr:
|
||||||
pushmlo <r0-r7> /* Save r0-r7 on the stack */
|
pushmlo <r0-r7> /* Save r0-r7 on the stack */
|
||||||
ld r1, #Z16F_IRQ_P7AD /* r1 = Port A/D7, rising/falling edge IRQ number */
|
ld r1, #Z16F_IRQ_P7AD /* r1 = Port A/D7, rising/falling edge IRQ number */
|
||||||
jp _common_isr /* Join common interrupt handling logic */
|
jp _common_isr /* Join common interrupt handling logic */
|
||||||
|
|
||||||
_p6ad_isr:
|
_p6ad_isr:
|
||||||
pushmlo <r0-r7> /* Save r0-r7 on the stack */
|
pushmlo <r0-r7> /* Save r0-r7 on the stack */
|
||||||
ld r1, #Z16F_IRQ_P6AD /* r1 = Port A/D6, rising/falling edge IRQ number */
|
ld r1, #Z16F_IRQ_P6AD /* r1 = Port A/D6, rising/falling edge IRQ number */
|
||||||
jp _common_isr /* Join common interrupt handling logic */
|
jp _common_isr /* Join common interrupt handling logic */
|
||||||
|
|
||||||
_p5ad_isr:
|
_p5ad_isr:
|
||||||
pushmlo <r0-r7> /* Save r0-r7 on the stack */
|
pushmlo <r0-r7> /* Save r0-r7 on the stack */
|
||||||
ld r1, #Z16F_IRQ_P5AD /* r1 = Port A/D5, rising/falling edge IRQ number */
|
ld r1, #Z16F_IRQ_P5AD /* r1 = Port A/D5, rising/falling edge IRQ number */
|
||||||
jp _common_isr /* Join common interrupt handling logic */
|
jp _common_isr /* Join common interrupt handling logic */
|
||||||
|
|
||||||
_p4ad_isr:
|
_p4ad_isr:
|
||||||
pushmlo <r0-r7> /* Save r0-r7 on the stack */
|
pushmlo <r0-r7> /* Save r0-r7 on the stack */
|
||||||
ld r1, #Z16F_IRQ_P4AD /* r1 = Port A/D4, rising/falling edge IRQ number */
|
ld r1, #Z16F_IRQ_P4AD /* r1 = Port A/D4, rising/falling edge IRQ number */
|
||||||
jp _common_isr /* Join common interrupt handling logic */
|
jp _common_isr /* Join common interrupt handling logic */
|
||||||
|
|
||||||
_p3ad_isr:
|
_p3ad_isr:
|
||||||
pushmlo <r0-r7> /* Save r0-r7 on the stack */
|
pushmlo <r0-r7> /* Save r0-r7 on the stack */
|
||||||
ld r1, #Z16F_IRQ_P3AD /* r1 = Port A/D3, rising/falling edgeEXEC IRQ number */
|
ld r1, #Z16F_IRQ_P3AD /* r1 = Port A/D3, rising/falling edgeEXEC IRQ number */
|
||||||
jp _common_isr /* Join common interrupt handling logic */
|
jp _common_isr /* Join common interrupt handling logic */
|
||||||
|
|
||||||
_p2ad_isr:
|
_p2ad_isr:
|
||||||
pushmlo <r0-r7> /* Save r0-r7 on the stack */
|
pushmlo <r0-r7> /* Save r0-r7 on the stack */
|
||||||
ld r1, #Z16F_IRQ_P2AD /* r1 = Port A/D2, rising/falling edge IRQ number */
|
ld r1, #Z16F_IRQ_P2AD /* r1 = Port A/D2, rising/falling edge IRQ number */
|
||||||
jp _common_isr /* Join common interrupt handling logic */
|
jp _common_isr /* Join common interrupt handling logic */
|
||||||
|
|
||||||
_p1ad_isr:
|
_p1ad_isr:
|
||||||
pushmlo <r0-r7> /* Save r0-r7 on the stack */
|
pushmlo <r0-r7> /* Save r0-r7 on the stack */
|
||||||
ld r1, #Z16F_IRQ_P1AD /* r1 = Port A/D1, rising/falling edge IRQ number */
|
ld r1, #Z16F_IRQ_P1AD /* r1 = Port A/D1, rising/falling edge IRQ number */
|
||||||
jp _common_isr /* Join common interrupt handling logic */
|
jp _common_isr /* Join common interrupt handling logic */
|
||||||
|
|
||||||
_p0ad_isr:
|
_p0ad_isr:
|
||||||
pushmlo <r0-r7> /* Save r0-r7 on the stack */
|
pushmlo <r0-r7> /* Save r0-r7 on the stack */
|
||||||
ld r1, #Z16F_IRQ_P0AD /* r1 = Port A/D0, rising/falling edge IRQ number */
|
ld r1, #Z16F_IRQ_P0AD /* r1 = Port A/D0, rising/falling edge IRQ number */
|
||||||
jp _common_isr /* Join common interrupt handling logic */
|
jp _common_isr /* Join common interrupt handling logic */
|
||||||
|
|
||||||
_pwmtimer_isr:
|
_pwmtimer_isr:
|
||||||
pushmlo <r0-r7> /* Save r0-r7 on the stack */
|
pushmlo <r0-r7> /* Save r0-r7 on the stack */
|
||||||
ld r1, #Z16F_IRQ_PWMTIMER /* r1 = PWM Timer IRQ number */
|
ld r1, #Z16F_IRQ_PWMTIMER /* r1 = PWM Timer IRQ number */
|
||||||
jp _common_isr /* Join common interrupt handling logic */
|
jp _common_isr /* Join common interrupt handling logic */
|
||||||
|
|
||||||
_uart1rx_isr:
|
_uart1rx_isr:
|
||||||
pushmlo <r0-r7> /* Save r0-r7 on the stack */
|
pushmlo <r0-r7> /* Save r0-r7 on the stack */
|
||||||
ld r1, #Z16F_IRQ_UART1RX /* r1 = UART1 RX IRQ number */
|
ld r1, #Z16F_IRQ_UART1RX /* r1 = UART1 RX IRQ number */
|
||||||
jp _common_isr /* Join common interrupt handling logic */
|
jp _common_isr /* Join common interrupt handling logic */
|
||||||
|
|
||||||
_uart1tx_isr:
|
_uart1tx_isr:
|
||||||
pushmlo <r0-r7> /* Save r0-r7 on the stack */
|
pushmlo <r0-r7> /* Save r0-r7 on the stack */
|
||||||
ld r1, #Z16F_IRQ_UART1TX /* r1 = UART1 TX IRQ number */
|
ld r1, #Z16F_IRQ_UART1TX /* r1 = UART1 TX IRQ number */
|
||||||
jp _common_isr /* Join common interrupt handling logic */
|
jp _common_isr /* Join common interrupt handling logic */
|
||||||
|
|
||||||
_pwmfault_isr:
|
_pwmfault_isr:
|
||||||
pushmlo <r0-r7> /* Save r0-r7 on the stack */
|
pushmlo <r0-r7> /* Save r0-r7 on the stack */
|
||||||
ld r1, #Z16F_IRQ_PWMFAULT /* r1 = PWM Fault IRQ number */
|
ld r1, #Z16F_IRQ_PWMFAULT /* r1 = PWM Fault IRQ number */
|
||||||
jp _common_isr /* Join common interrupt handling logic */
|
jp _common_isr /* Join common interrupt handling logic */
|
||||||
|
|
||||||
_c3_isr:
|
_c3_isr:
|
||||||
pushmlo <r0-r7> /* Save r0-r7 on the stack */
|
pushmlo <r0-r7> /* Save r0-r7 on the stack */
|
||||||
ld r1, #Z16F_IRQ_C3 /* r1 = Port C3, both edges DMA3 IRQ number */
|
ld r1, #Z16F_IRQ_C3 /* r1 = Port C3, both edges DMA3 IRQ number */
|
||||||
jp _common_isr /* Join common interrupt handling logic */
|
jp _common_isr /* Join common interrupt handling logic */
|
||||||
|
|
||||||
_c2_isr:
|
_c2_isr:
|
||||||
pushmlo <r0-r7> /* Save r0-r7 on the stack */
|
pushmlo <r0-r7> /* Save r0-r7 on the stack */
|
||||||
ld r1, #Z16F_IRQ_C2 /* r1 = Port C2, both edges DMA2 IRQ number */
|
ld r1, #Z16F_IRQ_C2 /* r1 = Port C2, both edges DMA2 IRQ number */
|
||||||
jp _common_isr /* Join common interrupt handling logic */
|
jp _common_isr /* Join common interrupt handling logic */
|
||||||
|
|
||||||
_c1_isr:
|
_c1_isr:
|
||||||
pushmlo <r0-r7> /* Save r0-r7 on the stack */
|
pushmlo <r0-r7> /* Save r0-r7 on the stack */
|
||||||
ld r1, #Z16F_IRQ_C1 /* r1 = Port C1, both edges DMA1 IRQ number */
|
ld r1, #Z16F_IRQ_C1 /* r1 = Port C1, both edges DMA1 IRQ number */
|
||||||
jp _common_isr /* Join common interrupt handling logic */
|
jp _common_isr /* Join common interrupt handling logic */
|
||||||
|
|
||||||
_c0_isr:
|
_c0_isr:
|
||||||
pushmlo <r0-r7> /* Save r0-r7 on the stack */
|
pushmlo <r0-r7> /* Save r0-r7 on the stack */
|
||||||
ld r1, #Z16F_IRQ_C0 /* r1 = Port C0, both edges DMA0 IRQ number */
|
ld r1, #Z16F_IRQ_C0 /* r1 = Port C0, both edges DMA0 IRQ number */
|
||||||
/* Join common interrupt handling logic */
|
/* Join common interrupt handling logic */
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* Name: _common_isr
|
* Name: _common_isr
|
||||||
@ -437,9 +436,9 @@ _common_isr:
|
|||||||
* push that as the saved value of r15=sp
|
* push that as the saved value of r15=sp
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ld r2, #(9*4+2) /* See stack accounting above */
|
ld r2, #(9*4+2) /* See stack accounting above */
|
||||||
add r2, sp /* r1 = Value of the SP before the interrupt */
|
add r2, sp /* r1 = Value of the SP before the interrupt */
|
||||||
push r2 /* Push r1 in the spot for the saved SP */
|
push r2 /* Push r1 in the spot for the saved SP */
|
||||||
|
|
||||||
/* Save all of the remaining registers */
|
/* Save all of the remaining registers */
|
||||||
|
|
||||||
@ -450,7 +449,7 @@ _common_isr:
|
|||||||
* arg2(r2)=address of the register save structure.
|
* arg2(r2)=address of the register save structure.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ld r2, sp
|
ld r2, sp
|
||||||
call _up_doirq
|
call _up_doirq
|
||||||
|
|
||||||
/* Upon return, _up_doirq will provide that address of the save structure
|
/* Upon return, _up_doirq will provide that address of the save structure
|
||||||
@ -458,11 +457,11 @@ _common_isr:
|
|||||||
* same value as sp.
|
* same value as sp.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
cp r0, sp /* Check if we are performing a context switch */
|
cp r0, sp /* Check if we are performing a context switch */
|
||||||
jp nz, _common_switch /* Jump if yes, else use faster return */
|
jp nz, _common_switch /* Jump if yes, else use faster return */
|
||||||
popmhi <r8-r14> /* Restore r8-r14 */
|
popmhi <r8-r14> /* Restore r8-r14 */
|
||||||
add sp, #4 /* Skip over restore of r15=sp */
|
add sp, #4 /* Skip over restore of r15=sp */
|
||||||
popmlo <r0-r7> /* Restore r0-r7 */
|
popmlo <r0-r7> /* Restore r0-r7 */
|
||||||
iret
|
iret
|
||||||
|
|
||||||
/* We are not returning to the same thread that was interrupted. In this case,
|
/* We are not returning to the same thread that was interrupted. In this case,
|
||||||
@ -470,21 +469,21 @@ _common_isr:
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
_common_switch:
|
_common_switch:
|
||||||
ld sp, 2*REG_SP(r0) /* sp=Value of SP on return from interrupt */
|
ld sp, 2*REG_SP(r0) /* sp=Value of SP on return from interrupt */
|
||||||
ld.w r1, 2*REG_FLAGS(r0) /* r1=padded flags value */
|
ld.w r1, 2*REG_FLAGS(r0) /* r1=padded flags value */
|
||||||
push.w r1 /* Push padded flags value onto the stack */
|
push.w r1 /* Push padded flags value onto the stack */
|
||||||
ld r1, 2*REG_PC(r0) /* r1=return address */
|
ld r1, 2*REG_PC(r0) /* r1=return address */
|
||||||
push r1 /* Push the return address onto the stack */
|
push r1 /* Push the return address onto the stack */
|
||||||
ld r7, 2*REG_R7(r0) /* Recover saved r7 */
|
ld r7, 2*REG_R7(r0) /* Recover saved r7 */
|
||||||
push r7 /* And save on the stack so that we can use r7 */
|
push r7 /* And save on the stack so that we can use r7 */
|
||||||
ld r7, sp /* r7=saved sp */
|
ld r7, sp /* r7=saved sp */
|
||||||
|
|
||||||
ld sp, r0 /* sp=Pointer to register save structure */
|
ld sp, r0 /* sp=Pointer to register save structure */
|
||||||
popmhi <r8-r14> /* Restore r8-r14 */
|
popmhi <r8-r14> /* Restore r8-r14 */
|
||||||
add sp, #4 /* Skip over restore of r15=sp */
|
add sp, #4 /* Skip over restore of r15=sp */
|
||||||
popmlo <r0-r6> /* Restore r0-r6 */
|
popmlo <r0-r6> /* Restore r0-r6 */
|
||||||
ld sp, r7 /* Switch back to the correct stack */
|
ld sp, r7 /* Switch back to the correct stack */
|
||||||
pop r7 /* Recover r7 from the stack */
|
pop r7 /* Recover r7 from the stack */
|
||||||
iret /* Return from interrupt */
|
iret /* Return from interrupt */
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -90,7 +90,7 @@
|
|||||||
* Description:
|
* Description:
|
||||||
* Initialize UART0 or UART1
|
* Initialize UART0 or UART1
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Input Parameters:
|
||||||
* None
|
* None
|
||||||
*
|
*
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
@ -103,7 +103,7 @@ _z16f_lowuartinit:
|
|||||||
#ifdef CONFIG_UART1_SERIAL_CONSOLE
|
#ifdef CONFIG_UART1_SERIAL_CONSOLE
|
||||||
ld r3, #CONFIG_UART1_BAUD /* r3 = Selected UART1 baud */
|
ld r3, #CONFIG_UART1_BAUD /* r3 = Selected UART1 baud */
|
||||||
#else
|
#else
|
||||||
ld r3, #CONFIG_UART0_BAUD /* r3 = Selected UART0 (default) baud */
|
ld r3, #CONFIG_UART0_BAUD /* r3 = Selected UART0 (default) baud */
|
||||||
#endif
|
#endif
|
||||||
ld r0, r3 /* r0 = baud */
|
ld r0, r3 /* r0 = baud */
|
||||||
sll r0, #3 /* r0 = baud * 8 */
|
sll r0, #3 /* r0 = baud * 8 */
|
||||||
@ -111,8 +111,10 @@ _z16f_lowuartinit:
|
|||||||
sll r3, #4 /* r3 = baud * 16 */
|
sll r3, #4 /* r3 = baud * 16 */
|
||||||
udiv r0, r3 /* BRG = (freq + baud * 8)/(baud * 16) */
|
udiv r0, r3 /* BRG = (freq + baud * 8)/(baud * 16) */
|
||||||
|
|
||||||
|
/* Hacks to get a serial console available ASAP */
|
||||||
|
|
||||||
#ifdef CONFIG_UART1_SERIAL_CONSOLE
|
#ifdef CONFIG_UART1_SERIAL_CONSOLE
|
||||||
ld.w Z16F_UART1_BR, r0 /* Z16F_UART1_BR = BRG */
|
ld.w Z16F_UART1_BR, r0 /* Z16F_UART1_BR = BRG */
|
||||||
|
|
||||||
/* Set the GPIO Alternate Function Register Lo (AFL) register */
|
/* Set the GPIO Alternate Function Register Lo (AFL) register */
|
||||||
|
|
||||||
@ -152,10 +154,10 @@ _z16f_lowuartinit:
|
|||||||
* Description:
|
* Description:
|
||||||
* Send one character to the selected serial console
|
* Send one character to the selected serial console
|
||||||
*
|
*
|
||||||
* Parmeters:
|
* Input Parameters:
|
||||||
* r1 = character
|
* r1 = character
|
||||||
*
|
*
|
||||||
* Return:
|
* Returned Value:
|
||||||
* None
|
* None
|
||||||
*
|
*
|
||||||
* Modifies r0 (and maybe r1)
|
* Modifies r0 (and maybe r1)
|
||||||
|
@ -435,6 +435,7 @@ static int z16f_attach(struct uart_dev_s *dev)
|
|||||||
irq_detach(priv->rxirq);
|
irq_detach(priv->rxirq);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -451,8 +452,10 @@ static int z16f_attach(struct uart_dev_s *dev)
|
|||||||
static void z16f_detach(struct uart_dev_s *dev)
|
static void z16f_detach(struct uart_dev_s *dev)
|
||||||
{
|
{
|
||||||
struct z16f_uart_s *priv = (struct z16f_uart_s*)dev->priv;
|
struct z16f_uart_s *priv = (struct z16f_uart_s*)dev->priv;
|
||||||
|
|
||||||
up_disable_irq(priv->rxirq);
|
up_disable_irq(priv->rxirq);
|
||||||
up_disable_irq(priv->txirq);
|
up_disable_irq(priv->txirq);
|
||||||
|
|
||||||
irq_detach(priv->rxirq);
|
irq_detach(priv->rxirq);
|
||||||
irq_detach(priv->txirq);
|
irq_detach(priv->txirq);
|
||||||
}
|
}
|
||||||
@ -484,8 +487,8 @@ static int z16f_rxinterrupt(int irq, void *context)
|
|||||||
{
|
{
|
||||||
dev = &g_uart0port;
|
dev = &g_uart0port;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
else
|
else
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
PANIC();
|
PANIC();
|
||||||
}
|
}
|
||||||
@ -504,7 +507,7 @@ static int z16f_rxinterrupt(int irq, void *context)
|
|||||||
|
|
||||||
if (status & Z16F_UARTSTAT0_RDA)
|
if (status & Z16F_UARTSTAT0_RDA)
|
||||||
{
|
{
|
||||||
/* Handline an incoming, receive byte */
|
/* Handle an incoming, received byte */
|
||||||
|
|
||||||
uart_recvchars(dev);
|
uart_recvchars(dev);
|
||||||
}
|
}
|
||||||
@ -539,8 +542,8 @@ static int z16f_txinterrupt(int irq, void *context)
|
|||||||
{
|
{
|
||||||
dev = &g_uart0port;
|
dev = &g_uart0port;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
else
|
else
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
PANIC();
|
PANIC();
|
||||||
}
|
}
|
||||||
@ -593,6 +596,7 @@ static int z16f_receive(struct uart_dev_s *dev, uint32_t *status)
|
|||||||
rxd = getreg8(priv->uartbase + Z16F_UART_RXD);
|
rxd = getreg8(priv->uartbase + Z16F_UART_RXD);
|
||||||
stat0 = getreg8(priv->uartbase + Z16F_UART_STAT0);
|
stat0 = getreg8(priv->uartbase + Z16F_UART_STAT0);
|
||||||
*status = (uint32_t)rxd | (((uint32_t)stat0) << 8);
|
*status = (uint32_t)rxd | (((uint32_t)stat0) << 8);
|
||||||
|
|
||||||
return rxd;
|
return rxd;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -730,15 +734,46 @@ static bool z16f_txempty(struct uart_dev_s *dev)
|
|||||||
|
|
||||||
void up_earlyserialinit(void)
|
void up_earlyserialinit(void)
|
||||||
{
|
{
|
||||||
/* REVISIT: UART GPIO AFL register is not initialized */
|
uint8_t regval;
|
||||||
|
|
||||||
|
/* Configure UART alternate pin functions */
|
||||||
|
|
||||||
|
#ifdef CONFIG_Z16F_UART0
|
||||||
|
/* UART0 is PA4 and PA5, alternate function 1 */
|
||||||
|
|
||||||
|
regval = getreg8(Z16F_GPIOA_AFL);
|
||||||
|
regval |= 0x30;
|
||||||
|
putreg8(regval, Z16F_GPIOA_AFL);
|
||||||
|
|
||||||
|
regval = getreg8(Z16F_GPIOA_AFH);
|
||||||
|
regval &= ~0x30;
|
||||||
|
putreg8(regval, Z16F_GPIOA_AFH);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_Z16F_UART1
|
||||||
|
/* UART1 is PD4 and PD5, alternate function 1 */
|
||||||
|
|
||||||
|
regval = getreg8(Z16F_GPIOD_AFL);
|
||||||
|
regval |= 0x30;
|
||||||
|
putreg8(regval, Z16F_GPIOD_AFL);
|
||||||
|
|
||||||
|
regval = getreg8(Z16F_GPIOD_AFH);
|
||||||
|
regval &= ~0x30;
|
||||||
|
putreg8(regval, Z16F_GPIOD_AFH);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Disable UART interrupts */
|
||||||
|
|
||||||
#ifdef TTYS0_DEV
|
#ifdef TTYS0_DEV
|
||||||
(void)z16f_disableuartirq(&TTYS0_DEV);
|
(void)z16f_disableuartirq(&TTYS0_DEV);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef TTYS1_DEV
|
#ifdef TTYS1_DEV
|
||||||
(void)z16f_disableuartirq(&TTYS1_DEV);
|
(void)z16f_disableuartirq(&TTYS1_DEV);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Configuration any serial console */
|
||||||
|
|
||||||
#ifdef CONSOLE_DEV
|
#ifdef CONSOLE_DEV
|
||||||
CONSOLE_DEV.isconsole = true;
|
CONSOLE_DEV.isconsole = true;
|
||||||
z16f_setup(&CONSOLE_DEV);
|
z16f_setup(&CONSOLE_DEV);
|
||||||
|
Loading…
Reference in New Issue
Block a user