I need to use adc in pru0, and after i config adc register, there is no data.
Code:
#include <stdint.h>
#include <stdio.h>
#include <pru_cfg.h>
#include <pru_intc.h>
#include <rsc_types.h>
#include <pru_rpmsg.h>
#include "resource_table_0.h"
/* Shared memory block struct */
struct shared_mem {
    volatile char init_flag;
    volatile int output;
};
/* Shared memory setup */
#pragma DATA_SECTION(share_buff, ".share_buff")
volatile far struct shared_mem share_buff;
volatile register uint32_t __R30;
volatile register uint32_t __R31;
/* Non-CT register defines */
#define ADC_CTRL			(*((volatile unsigned int *)0x44E0D040))
#define ADC_STEPENABLE 		(*((volatile unsigned int *)0x44E0D054))
#define ADC_STEPCONFIG1 	(*((volatile unsigned int *)0x44E0D064))
#define ADC_STEPDELAY1 		(*((volatile unsigned int *)0x44E0D068))
#define ADC_FIFO1THRESHOLD 	(*((volatile unsigned int *)0x44E0D0F4))
#define ADC_FIFO1CNT 	(*((volatile unsigned int *)0x44E0D0F0))
#define ADC_FIFO1DATA 		(*((volatile unsigned int *)0x44E0D200))
#define FIFOREAD_CHNLID_MASK (0xf << 16)
#define FIFOREAD_DATA_MASK (0xfff << 0)
/* Host-0 Interrupt sets bit 30 in register R31 */
#define HOST_INT			((uint32_t) 1 << 30)
/* The PRU-ICSS system events used for RPMsg are defined in the Linux device tree
 * PRU0 uses system event 16 (To ARM) and 17 (From ARM)
 * PRU1 uses system event 18 (To ARM) and 19 (From ARM)
 */
#define TO_ARM_HOST			16
#define FROM_ARM_HOST		17
/*
* Using the name 'rpmsg-pru' will probe the rpmsg_pru driver found
* at linux-x.y.z/drivers/rpmsg/rpmsg_pru.c
*/
#define CHAN_NAME			"rpmsg-pru"
#define CHAN_DESC			"Channel 30"
#define CHAN_PORT			30
/*
 * Used to make sure the Linux drivers are ready for RPMsg communication
 * Found at linux-x.y.z/include/uapi/linux/virtio_config.h
 */
#define VIRTIO_CONFIG_S_DRIVER_OK	4
uint8_t payload[RPMSG_BUF_SIZE];
void init_adc(void)
{
	ADC_CTRL = 0x7;
	ADC_STEPCONFIG1 = 0x4200010;
	ADC_STEPDELAY1 = 0x98;
	ADC_FIFO1THRESHOLD = 0x13;
}
/*
 * main.c
 */
void main(void)
{
	struct pru_rpmsg_transport transport;
	uint16_t src, dst, len;
	volatile uint8_t *status;
	__R30 = 0x0;
	/* Allow OCP master port access by the PRU so the PRU can read external memories */
	CT_CFG.SYSCFG_bit.STANDBY_INIT = 0;
	init_adc();
	/* Clear the status of the PRU-ICSS system event that the ARM will use to 'kick' us */
	CT_INTC.SICR_bit.STS_CLR_IDX = FROM_ARM_HOST;
	/* Make sure the Linux drivers are ready for RPMsg communication */
	status = &resourceTable.rpmsg_vdev.status;
	while (!(*status & VIRTIO_CONFIG_S_DRIVER_OK));
	/* Initialize the RPMsg transport structure */
	pru_rpmsg_init(&transport, &resourceTable.rpmsg_vring0, &resourceTable.rpmsg_vring1, TO_ARM_HOST, FROM_ARM_HOST);
	/* Create the RPMsg channel between the PRU and ARM user space using the transport structure. */
	while (pru_rpmsg_channel(RPMSG_NS_CREATE, &transport, CHAN_NAME, CHAN_DESC, CHAN_PORT) != PRU_RPMSG_SUCCESS);
	while (1) {
		/* Check bit 30 of register R31 to see if the ARM has kicked us */
		if (__R31 & HOST_INT) {
			/* Clear the event status */
			CT_INTC.SICR_bit.STS_CLR_IDX = FROM_ARM_HOST;
			/* Receive all available messages, multiple messages can be sent per kick */
			while (pru_rpmsg_receive(&transport, &src, &dst, payload, &len) == PRU_RPMSG_SUCCESS) {
				int i;
				for (i = 0; i < len; i++) {
					if (payload[i] == 'b' || payload[i] == 'B')
						share_buff.output = 0x800;
					else if (payload[i] == 'g' || payload[i] == 'G')
						share_buff.output = 0x400;
					else if (payload[i] == 'o' || payload[i] == 'O')
						share_buff.output = 0x200;
					else if (payload[i] == 'r' || payload[i] == 'R')
						share_buff.output = 0x0;
					else if (payload[i] == 's')
					{
						ADC_CTRL &= 0xFFFFFFFD;
						ADC_STEPCONFIG1 &= 0xFFFFFFE3;
					}
					else if (payload[i] == 'S')
					{
						ADC_CTRL |= 0x2;
						ADC_STEPCONFIG1 |= 0x1C;
					}
					volatile uint32_t fifo1count;
					while(1)
					{
						fifo1count = ADC_FIFO1CNT;
						if (fifo1count)
							break;
					}
					payload[0] = fifo1count + 0x30;
					pru_rpmsg_send(&transport, dst, src, payload, 2);
				}
			}
		}
	}
}
								 
				 
		 
					 
                           
				 
				