Skip to content

Commit

Permalink
Merge pull request #1 from RedPitaya/master
Browse files Browse the repository at this point in the history
updated with upstream
  • Loading branch information
AndreasJochum authored Nov 18, 2020
2 parents 13a70c7 + 040c389 commit 12bebd7
Show file tree
Hide file tree
Showing 375 changed files with 25,963 additions and 13,029 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Release (1.03-701)
# Release (1.04-7)

- The streaming application was improved. One of the main features is that users can now exactly know when and which samples are lost due to throughput problems or limitation
- Watchdog was implemented for Linux and WEB applications. In case of fatal error or lost connection device will always return to its previous operation state.
- Open source FPGA code can now be compiled with Vivado 2020.1
- New OS available notification was implemented into WEB interface
other general improvements and updates
- Added application for calibrating RP

# Stable version (1.03-701)
General improvements:
- Access point working with official WIFI dongle
- Client WIFI mode fixed
Expand Down
10 changes: 9 additions & 1 deletion CHANGELOG_Z20.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
# Release (1.03-6)
# Release (1.04-8)

- The streaming application was improved. One of the main features is that users can now exactly know when and which samples are lost due to throughput problems or limitation
- Watchdog was implemented for Linux and WEB applications. In case of fatal error or lost connection device will always return to its previous operation state.
- Open source FPGA code can now be compiled with Vivado 2020.1
- New OS available notification was implemented into WEB interface
other general improvements and updates

# Stable version (1.03-6)

General improvements:
- Access point working with official WIFI dongle
Expand Down
11 changes: 10 additions & 1 deletion CHANGELOG_Z20_250_12.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
# Release (1.03-1)
# Release (1.04-19)

- The streaming application was improved. One of the main features is that users can now exactly know when and which samples are lost due to throughput problems or limitation
- Watchdog was implemented for Linux and WEB applications. In case of fatal error or lost connection device will always return to its previous operation state.
- Open source FPGA code can now be compiled with Vivado 2020.1
- New OS available notification was implemented into WEB interface
other general improvements and updates
- Added application for calibrating RP
-
# Stable version (1.03-1)

General improvements:
- Access point working with official WIFI dongle
Expand Down
2 changes: 1 addition & 1 deletion Examples/C/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CFLAGS = -g -std=gnu99 -Wall -Werror
CFLAGS = -g -std=gnu11 -Wall -Werror
CFLAGS += -I/opt/redpitaya/include
LDFLAGS = -L/opt/redpitaya/lib
LDLIBS = -lm -lpthread -lrp
Expand Down
2 changes: 1 addition & 1 deletion Examples/C/acquire_trigger_posedge.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "redpitaya/rp.h"
#include "rp.h"

int main(int argc, char **argv){

Expand Down
2 changes: 1 addition & 1 deletion Examples/C/acquire_trigger_software.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "redpitaya/rp.h"
#include "rp.h"

int main(int argc, char **argv){

Expand Down
2 changes: 1 addition & 1 deletion Examples/C/analog_inputs.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <stdio.h>
#include <stdlib.h>

#include "redpitaya/rp.h"
#include "rp.h"

int main (int argc, char **argv) {
float value [4];
Expand Down
2 changes: 1 addition & 1 deletion Examples/C/analog_outputs.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <stdio.h>
#include <stdlib.h>

#include "redpitaya/rp.h"
#include "rp.h"

int main (int argc, char **argv) {
float value [4];
Expand Down
2 changes: 1 addition & 1 deletion Examples/C/digital_led_bar.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <stdlib.h>
#include <unistd.h>

#include "redpitaya/rp.h"
#include "rp.h"

int main (int argc, char **argv) {
float percent;
Expand Down
3 changes: 1 addition & 2 deletions Examples/C/digital_led_blink.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#include "redpitaya/rp.h"
#include "rp.h"

int main (int argc, char **argv) {
int unsigned period = 1000000; // uS
Expand Down
2 changes: 1 addition & 1 deletion Examples/C/digital_push_button.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <stdio.h>
#include <stdlib.h>

#include "redpitaya/rp.h"
#include "rp.h"

int main (int argc, char **argv) {
rp_pinState_t state;
Expand Down
2 changes: 1 addition & 1 deletion Examples/C/generate_arbitrary_waveform.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <stdlib.h>
#include <math.h>

#include "redpitaya/rp.h"
#include "rp.h"

#define M_PI 3.14159265358979323846

Expand Down
2 changes: 1 addition & 1 deletion Examples/C/generate_burst_trigger_external.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <stdlib.h>
#include <unistd.h>

#include "redpitaya/rp.h"
#include "rp.h"


int main(int argc, char **argv){
Expand Down
2 changes: 1 addition & 1 deletion Examples/C/generate_burst_trigger_software.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <stdlib.h>
#include <unistd.h>

#include "redpitaya/rp.h"
#include "rp.h"

int main(int argc, char **argv){

Expand Down
2 changes: 1 addition & 1 deletion Examples/C/generate_continuous.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <stdlib.h>
#include <unistd.h>

#include "redpitaya/rp.h"
#include "rp.h"

int main(int argc, char **argv){

Expand Down
216 changes: 216 additions & 0 deletions Examples/C/i2c.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
/* @brief This is a simple application for testing IIC communication on a RedPitaya
* @Author Luka Golinar <[email protected]>
*
* (c) Red Pitaya http://www.redpitaya.com
*
* This part of code is written in C programming language.
* Please visit http://en.wikipedia.org/wiki/C_(programming_language)
* for more details on the language used herein.
*/


#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <linux/ioctl.h>
#include <sys/ioctl.h>
#include <linux/i2c-dev.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <stdint.h>


#define I2C_SLAVE_FORCE 0x0706
#define I2C_SLAVE 0x0703 /* Change slave address */
#define I2C_FUNCS 0x0705 /* Get the adapter functionality */
#define I2C_RDWR 0x0707 /* Combined R/W transfer (one stop only)*/


#define EEPROM_ADDR 0x50

/*
* Page size of the EEPROM. This depends on the type of the EEPROM available
* on board.
*/
#define PAGESIZE 32
/* eeprom size on a redpitaya */
#define EEPROMSIZE 64*1024/8


/* Inline functions definition */
static int iic_read(char *buffer, int offset, int size);
static int iic_write(char *data, int offset, int size);

/*
* File descriptors
*/
int fd;

int main(int argc, char *argv[])
{
int status;

/* Read buffer to hold the data */
char *buffer = (char *)malloc(EEPROMSIZE * sizeof(char));

char data[] = "THIS IS A TEST MESSAGE FOR THE I2C PROTOCOL COMMUNICATION WITH A EEPROM. IT WAS WRITTEN FOR A REDPITAYA MEASURMENT TOOL.";
size_t size = strlen(data);

/* Sample offset inside an eeprom */
int offset = 0x100;

/*
* Open the device.
*/
fd = open("/dev/i2c-0", O_RDWR);

if(fd < 0)
{
printf("Cannot open the IIC device\n");
return 1;
}

status = ioctl(fd, I2C_SLAVE_FORCE, EEPROM_ADDR);
if(status < 0)
{
printf("Unable to set the EEPROM address\n");
return -1;
}

/* Write to redpitaya eeprom */
status = iic_write((char *)data, offset, size);
if(status){
fprintf(stderr, "Cannot Write to EEPROM\n");
close(fd);
return -1;
}

/* Read from redpitaya eeprom */
status = iic_read(buffer, EEPROM_ADDR, EEPROMSIZE);
if (status)
{
printf("Cannot Read from EEPROM \n");
close(fd);
return 1;
}

printf("eerprom test successfull.\n");

/* Release allocations */
close(fd);
free(buffer);

return 0;
}

/* Read the data from the EEPROM.
*
* @param read buffer -- input buffer for data storage
* @param off set -- eeprom memory space offset
* @param size -- size of read data
* @return iicRead status
*
* @note None. */

static int iic_read(char *buffer, int offset, int size)
{
ssize_t bytes_written;
ssize_t bytes_read;
uint8_t write_buffer[2];

/*
* Load the offset address inside EEPROM where data need to be written.
* Supported for BigEndian and LittleEndian CPU's
*/
write_buffer[0] = (uint8_t)(offset >> 8);
write_buffer[1] = (uint8_t)(offset);

/* Write the bytes onto the bus */
bytes_written = write(fd, write_buffer, 2);
if(bytes_written < 0){
fprintf(stderr, "EEPROM write address error.\n");
return -1;
}

/*
* Read the bytes.
*/
printf ("Performing Read operation.\n");

/* Read bytes from the bus */
bytes_read = read(fd, buffer, size);
if(bytes_read < 0){
fprintf(stderr, "EEPROM read error.\n");
return -1;
}

printf("Read EEPROM Succesful\n");

return 0;
}


static int iic_write(char *data, int offset, int size){

/* variable declaration */
int bytes_written;
int write_bytes;
int index;

/* Check for limits */
if(size > PAGESIZE){
write_bytes = PAGESIZE;
}else{
write_bytes = size;
}

/* Number of needed loops to send all the data.
* Limit data size per transmission is PAGESIZE */
int loop = 0;

while(size > 0){

/* buffer size is PAGESIZE per transmission */
uint8_t write_buffer[32 + 2];

/*
* Load the offset address inside EEPROM where data need to be written.
* Supported for BigEndian and LittleEndian CPU's
*/
write_buffer[0] = (uint8_t)(offset >> 8);
write_buffer[1] = (uint8_t)(offset);

for(index = 0; index < PAGESIZE; index++){
write_buffer[index + 2] = data[index + (PAGESIZE * loop)];
}

/* Write the bytes onto the bus */
bytes_written = write(fd, write_buffer, write_bytes + 2);
/* Wait till the EEPROM internally completes the write cycle */
sleep(2);

if(bytes_written != write_bytes+2){
fprintf(stderr, "Failed to write to EEPROM\n");
return -1;
}

/* written bytes minus the offset addres of two */
size -= bytes_written - 2;
/* Increment offset */
offset += PAGESIZE;

/* Check for limits for the new message */
if(size > PAGESIZE){
write_bytes = PAGESIZE;
}else{
write_bytes = size;
}

loop++;
}

printf("\nWrite EEPROM Succesful\n");

return 0;
}
Loading

0 comments on commit 12bebd7

Please sign in to comment.