Mercurial > hg > beaglert
comparison pru_rtaudio.p @ 253:33e0e4831763 prerelease
Started prerelease branch; updated PRU code to be able to run on either PRU.
author | andrewm |
---|---|
date | Mon, 16 May 2016 12:13:58 +0100 |
parents | c706be7daad7 |
children | 5b490c00488f |
comparison
equal
deleted
inserted
replaced
252:381f352c44eb | 253:33e0e4831763 |
---|---|
80 #define COMM_LED_ADDRESS 24 // Which memory address to find the status LED on | 80 #define COMM_LED_ADDRESS 24 // Which memory address to find the status LED on |
81 #define COMM_LED_PIN_MASK 28 // Which pin to write to change LED | 81 #define COMM_LED_PIN_MASK 28 // Which pin to write to change LED |
82 #define COMM_FRAME_COUNT 32 // How many frames have elapse since beginning | 82 #define COMM_FRAME_COUNT 32 // How many frames have elapse since beginning |
83 #define COMM_USE_SPI 36 // Whether or not to use SPI ADC and DAC | 83 #define COMM_USE_SPI 36 // Whether or not to use SPI ADC and DAC |
84 #define COMM_NUM_CHANNELS 40 // Low 2 bits indicate 8 [0x3], 4 [0x1] or 2 [0x0] channels | 84 #define COMM_NUM_CHANNELS 40 // Low 2 bits indicate 8 [0x3], 4 [0x1] or 2 [0x0] channels |
85 #define COMM_USE_DIGITAL 44 // Whether or not to use DIGITAL | 85 #define COMM_USE_DIGITAL 44 // Whether or not to use DIGITAL |
86 #define COMM_PRU_NUMBER 48 // Which PRU this code is running on | |
86 | 87 |
87 #define MCASP0_BASE 0x48038000 | 88 #define MCASP0_BASE 0x48038000 |
88 #define MCASP1_BASE 0x4803C000 | 89 #define MCASP1_BASE 0x4803C000 |
89 | 90 |
90 #define MCASP_PWRIDLESYSCONFIG 0x04 | 91 #define MCASP_PWRIDLESYSCONFIG 0x04 |
547 AND r28, r28, r27 | 548 AND r28, r28, r27 |
548 QBEQ POLL, r28, 0 | 549 QBEQ POLL, r28, 0 |
549 .endm | 550 .endm |
550 | 551 |
551 START: | 552 START: |
552 // Set up c24 and c25 offsets with CTBIR register | |
553 // Thus C24 points to start of PRU0 RAM | |
554 MOV r3, 0x22020 // CTBIR0 | |
555 MOV r2, 0 | |
556 SBBO r2, r3, 0, 4 | |
557 | |
558 // Set up c28 pointer offset for shared PRU RAM | |
559 MOV r3, 0x22028 // CTPPR0 | |
560 MOV r2, 0x00000120 // To get address 0x00012000 | |
561 SBBO r2, r3, 0, 4 | |
562 | |
563 // Load useful registers for addressing SPI | 553 // Load useful registers for addressing SPI |
564 MOV reg_comm_addr, SHARED_COMM_MEM_BASE | 554 MOV reg_comm_addr, SHARED_COMM_MEM_BASE |
565 MOV reg_spi_addr, SPI_BASE | 555 MOV reg_spi_addr, SPI_BASE |
566 MOV reg_mcasp_addr, MCASP_BASE | 556 MOV reg_mcasp_addr, MCASP_BASE |
557 | |
558 // Find out which PRU we are running on | |
559 // This affects the following offsets | |
560 MOV r0, 0x24000 // PRU1 control register offset | |
561 LBBO r2, reg_comm_addr, COMM_PRU_NUMBER, 4 | |
562 QBEQ PRU_NUMBER_CHECK_DONE, r2, 1 | |
563 MOV r0, 0x22000 // PRU0 control register offset | |
564 PRU_NUMBER_CHECK_DONE: | |
565 | |
566 // Set up c24 and c25 offsets with CTBIR register | |
567 // Thus C24 points to start of PRU0 RAM | |
568 OR r3, r0, 0x20 // CTBIR0 | |
569 MOV r2, 0 | |
570 SBBO r2, r3, 0, 4 | |
571 | |
572 // Set up c28 pointer offset for shared PRU RAM | |
573 OR r3, r0, 0x28 // CTPPR0 | |
574 MOV r2, 0x00000120 // To get address 0x00012000 | |
575 SBBO r2, r3, 0, 4 | |
567 | 576 |
568 // Set ARM such that PRU can write to registers | 577 // Set ARM such that PRU can write to registers |
569 LBCO r0, C4, 4, 4 | 578 LBCO r0, C4, 4, 4 |
570 CLR r0, r0, 4 | 579 CLR r0, r0, 4 |
571 SBCO r0, C4, 4, 4 | 580 SBCO r0, C4, 4, 4 |