@@ -0,0 +1,12 | |||||
|
1 | TEMPLATE = app | |||
|
2 | CONFIG += cpu | |||
|
3 | ||||
|
4 | ||||
|
5 | UCMODEL=stm32f4 | |||
|
6 | BSP = SOLAR_LFR_PSU | |||
|
7 | ||||
|
8 | LIBS += -lN25Q128 | |||
|
9 | ||||
|
10 | SOURCES += \ | |||
|
11 | main.c | |||
|
12 |
@@ -0,0 +1,93 | |||||
|
1 | #include <stdio.h> | |||
|
2 | #include <fat32.h> | |||
|
3 | #include <gpio.h> | |||
|
4 | #include <uart.h> | |||
|
5 | #include <stm32f4xx.h> | |||
|
6 | #include <bsp.h> | |||
|
7 | #include <core.h> | |||
|
8 | #include <N25Q128.h> | |||
|
9 | #include <spi.h> | |||
|
10 | ||||
|
11 | extern streamdevice* __opnfiles__[]; | |||
|
12 | ||||
|
13 | /* | |||
|
14 | N25Q128 pinout: | |||
|
15 | MISO => PB14 | |||
|
16 | MOSI => PB15 | |||
|
17 | SCK => PB13 | |||
|
18 | CS => PB12 | |||
|
19 | WP => PC1 | |||
|
20 | RESET/HOLD => PC2 | |||
|
21 | */ | |||
|
22 | void cs(int csstate) | |||
|
23 | { | |||
|
24 | gpiosetval(PB12,csstate); | |||
|
25 | } | |||
|
26 | ||||
|
27 | void wp(int wpstate) | |||
|
28 | { | |||
|
29 | gpiosetval(PC1,wpstate); | |||
|
30 | } | |||
|
31 | ||||
|
32 | void resetHold(int rhstate) | |||
|
33 | { | |||
|
34 | gpiosetval(PC2,rhstate); | |||
|
35 | } | |||
|
36 | ||||
|
37 | int main() | |||
|
38 | { | |||
|
39 | spiopenandconfig(spi2,spiclkfirstedge|spimaster|spimsbfirst|spi8bits,10000,PB15,PB14,PB13,(uint32_t)NULL); | |||
|
40 | //spiopenandconfig(spi2,spiclkfirstedge|spimaster|spimsbfirst|spi8bits,10000,PB15,PB14,PB13,PB12); | |||
|
41 | gpio_t PC1pin= gpioopen(PC1); | |||
|
42 | gpiosetdir(&PC1pin,gpiooutdir); | |||
|
43 | gpio_t PC2pin= gpioopen(PC2); | |||
|
44 | gpiosetdir(&PC2pin,gpiooutdir); | |||
|
45 | gpio_t PB12pin= gpioopen(PB12); | |||
|
46 | gpiosetdir(&PB12pin,gpiooutdir); | |||
|
47 | gpioset(PC1); | |||
|
48 | gpioset(PB12); | |||
|
49 | gpioclr(PC2); | |||
|
50 | eepromN25Q128Dev eeprom; | |||
|
51 | eepromN25Q128open(&eeprom,spi2,&cs,&wp,&resetHold); | |||
|
52 | //eepromN25Q128open(&eeprom,spi2,NULL,&wp,&resetHold); | |||
|
53 | delay_100us(10); | |||
|
54 | gpioset(PC2); | |||
|
55 | gpioclr(PB12); | |||
|
56 | spiputw(spi2,0x9E); | |||
|
57 | char res[22]; | |||
|
58 | spigetnc(spi2,res,22); | |||
|
59 | gpioset(PB12); | |||
|
60 | for(int i=0;i<22;i++) | |||
|
61 | { | |||
|
62 | printf("res[%d] = 0x%x\n\r",i,(int)res[i]); | |||
|
63 | } | |||
|
64 | eepromN25Q128enablewrite(&eeprom); | |||
|
65 | delay_100us(10); | |||
|
66 | eepromN25Q128writen(&eeprom,0,"hello World",11); | |||
|
67 | delay_100us(10); | |||
|
68 | eepromN25Q128readn(&eeprom,0,res,11); | |||
|
69 | res[11]='\n'; | |||
|
70 | res[12]='\r'; | |||
|
71 | res[13]=0; | |||
|
72 | //printf("read: %s",res); | |||
|
73 | //printf("\n"); | |||
|
74 | for(int i=0;i<11;i++) | |||
|
75 | { | |||
|
76 | printf("res[%d] = 0x%x\n\r",i,(int)res[i]); | |||
|
77 | } | |||
|
78 | while(1) | |||
|
79 | { | |||
|
80 | gpioset(LED3); | |||
|
81 | delay_100us(10000); | |||
|
82 | gpioclr(LED3); | |||
|
83 | delay_100us(10000); | |||
|
84 | } | |||
|
85 | printf("hello world\n\r"); | |||
|
86 | return 0; | |||
|
87 | } | |||
|
88 | ||||
|
89 | ||||
|
90 | ||||
|
91 | ||||
|
92 | ||||
|
93 |
@@ -0,0 +1,15 | |||||
|
1 | TEMPLATE = app | |||
|
2 | CONFIG += cpu | |||
|
3 | ||||
|
4 | ||||
|
5 | UCMODEL=stm32f4 | |||
|
6 | DEFINES += CPUFREQ=160000000 | |||
|
7 | ||||
|
8 | #BSP = BEAGLESYNTH | |||
|
9 | #BSP = SOLAR_LFR_PSU | |||
|
10 | ||||
|
11 | BSP = STM32F4Eval | |||
|
12 | ||||
|
13 | SOURCES += \ | |||
|
14 | main.c | |||
|
15 |
@@ -0,0 +1,106 | |||||
|
1 | /* ---------------------------------------------------------------------- | |||
|
2 | * Copyright (C) 2010 ARM Limited. All rights reserved. | |||
|
3 | * | |||
|
4 | * $Date: 29. November 2010 | |||
|
5 | * $Revision: V1.0.3 | |||
|
6 | * | |||
|
7 | * Project: CMSIS DSP Library | |||
|
8 | * Title: arm_convolution_example_f32.c | |||
|
9 | * | |||
|
10 | * Description: Example code demonstrating Convolution of two input signals using fft. | |||
|
11 | * | |||
|
12 | * Target Processor: Cortex-M4/Cortex-M3 | |||
|
13 | * | |||
|
14 | * | |||
|
15 | * Version 1.0.3 2010/11/29 | |||
|
16 | * Re-organized the CMSIS folders and updated documentation. | |||
|
17 | * | |||
|
18 | * Version 1.0.1 2010/10/05 KK | |||
|
19 | * Production release and review comments incorporated. | |||
|
20 | * | |||
|
21 | * Version 1.0.0 2010/09/20 KK | |||
|
22 | * Production release and review comments incorporated. | |||
|
23 | * ------------------------------------------------------------------- */ | |||
|
24 | ||||
|
25 | #include <arm_math.h> | |||
|
26 | #include <math.h> | |||
|
27 | #include <stdio.h> | |||
|
28 | #include <gpio.h> | |||
|
29 | #include <bsp.h> | |||
|
30 | //#include "math_helper.h" | |||
|
31 | #include <terminal.h> | |||
|
32 | ||||
|
33 | /* ---------------------------------------------------------------------- | |||
|
34 | * Defines each of the tests performed | |||
|
35 | * ------------------------------------------------------------------- */ | |||
|
36 | //#define MAX_BLOCKSIZE 1024 | |||
|
37 | #define MAX_BLOCKSIZE 16 | |||
|
38 | ||||
|
39 | /* ---------------------------------------------------------------------- | |||
|
40 | * Declare I/O buffers | |||
|
41 | * ------------------------------------------------------------------- */ | |||
|
42 | float32_t Ak[MAX_BLOCKSIZE*2]; /* Input A */ | |||
|
43 | ||||
|
44 | #define LCD_COLOR_WHITE 0xFFFF | |||
|
45 | #define LCD_COLOR_BLACK 0x0000 | |||
|
46 | #define LCD_COLOR_GREY 0xF7DE | |||
|
47 | #define LCD_COLOR_BLUE 0x001F | |||
|
48 | #define LCD_COLOR_BLUE2 0x051F | |||
|
49 | #define LCD_COLOR_RED 0xF800 | |||
|
50 | #define LCD_COLOR_MAGENTA 0xF81F | |||
|
51 | #define LCD_COLOR_GREEN 0x07E0 | |||
|
52 | #define LCD_COLOR_CYAN 0x7FFF | |||
|
53 | #define LCD_COLOR_YELLOW 0xFFE0 | |||
|
54 | extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__]; | |||
|
55 | ||||
|
56 | ||||
|
57 | int main() | |||
|
58 | { | |||
|
59 | ||||
|
60 | arm_status status; /* Status of the example */ | |||
|
61 | arm_cfft_radix4_instance_f32 cfft_instance; /* CFFT Structure instance */ | |||
|
62 | ||||
|
63 | /* CFFT Structure instance pointer */ | |||
|
64 | arm_cfft_radix4_instance_f32 *cfft_instance_ptr = | |||
|
65 | (arm_cfft_radix4_instance_f32*) &cfft_instance; | |||
|
66 | ||||
|
67 | /* Initialise the fft input buffers with all zeros */ | |||
|
68 | arm_fill_f32(0.0, Ak, MAX_BLOCKSIZE); | |||
|
69 | for(int i =0;i<(MAX_BLOCKSIZE);i++) | |||
|
70 | { | |||
|
71 | Ak[2*i] = sin(4.0*PI*(float32_t)i/MAX_BLOCKSIZE); | |||
|
72 | printf("%f\n\r",Ak[i]); | |||
|
73 | } | |||
|
74 | ||||
|
75 | //gpioclr(LED1); | |||
|
76 | ||||
|
77 | /* Initialize the CFFT function to compute 64 point fft */ | |||
|
78 | status = arm_cfft_radix4_init_f32(cfft_instance_ptr, MAX_BLOCKSIZE, 0, 1); | |||
|
79 | ||||
|
80 | /* Transform input a[n] from time domain to frequency domain A[k] */ | |||
|
81 | arm_cfft_radix4_f32(cfft_instance_ptr, Ak); | |||
|
82 | ||||
|
83 | //gpioset(LED1); | |||
|
84 | ||||
|
85 | /* Initialize the CIFFT function to compute 64 point ifft */ | |||
|
86 | //status = arm_cfft_radix4_init_f32(cfft_instance_ptr, 16, 1, 1); | |||
|
87 | ||||
|
88 | /* Transform the multiplication output from frequency domain to time domain, | |||
|
89 | that gives the convolved output */ | |||
|
90 | //arm_cfft_radix4_f32(cfft_instance_ptr, AxB); | |||
|
91 | ||||
|
92 | /* SNR Calculation */ | |||
|
93 | //snr = arm_snr_f32((float32_t *)testRefOutput_f32, AxB, srcALen + srcBLen - 1); | |||
|
94 | ||||
|
95 | /* Compare the SNR with threshold to test whether the | |||
|
96 | computed output is matched with the reference output values. */ | |||
|
97 | printf("FFT Done!\n\r"); | |||
|
98 | for(int i =0;i<(MAX_BLOCKSIZE*2);i++) | |||
|
99 | { | |||
|
100 | printf("%f %f\n\r",Ak[2*i],Ak[(2*i)+1]); | |||
|
101 | } | |||
|
102 | ||||
|
103 | ||||
|
104 | while(1); /* main function does not return */ | |||
|
105 | } | |||
|
106 |
@@ -0,0 +1,56 | |||||
|
1 | /*------------------------------------------------------------------------------ | |||
|
2 | #-- This file is a part of the libuc, microcontroler library | |||
|
3 | #-- Copyright (C) 2011, Alexis Jeandet | |||
|
4 | #-- | |||
|
5 | #-- This program is free software; you can redistribute it and/or modify | |||
|
6 | #-- it under the terms of the GNU General Public License as published by | |||
|
7 | #-- the Free Software Foundation; either version 3 of the License, or | |||
|
8 | #-- (at your option) any later version. | |||
|
9 | #-- | |||
|
10 | #-- This program is distributed in the hope that it will be useful, | |||
|
11 | #-- but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
|
12 | #-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
|
13 | #-- GNU General Public License for more details. | |||
|
14 | #-- | |||
|
15 | #-- You should have received a copy of the GNU General Public License | |||
|
16 | #-- along with this program; if not, write to the Free Software | |||
|
17 | #-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |||
|
18 | #------------------------------------------------------------------------------- | |||
|
19 | #-- Author : Alexis Jeandet | |||
|
20 | #-- Mail : alexis.jeandet@gmail.com | |||
|
21 | #-------------------------------------------------------------------------------*/ | |||
|
22 | #include "spi.h" | |||
|
23 | #include "VS10XX.h" | |||
|
24 | //#include <bsp.h> | |||
|
25 | ||||
|
26 | void vs10XXopen(vs10XXDev* codec,spi_t dev){ | |||
|
27 | codec->SPIdev = dev; | |||
|
28 | ||||
|
29 | } | |||
|
30 | ||||
|
31 | void vs10XXsoftreset(vs10XXDev* dev) | |||
|
32 | { | |||
|
33 | vs10XXcmdwrite(dev,VSMODE,(1<<2)); | |||
|
34 | } | |||
|
35 | ||||
|
36 | int vs10XXcmdread(vs10XXDev* dev,char address) | |||
|
37 | { | |||
|
38 | int result; | |||
|
39 | while(!vs10XXDREQ()); | |||
|
40 | vs10XXclearXCS(); | |||
|
41 | spiputw(dev->SPIdev,(3<<8)+address); | |||
|
42 | result = spigetw(dev->SPIdev); | |||
|
43 | vs10XXsetXCS(); | |||
|
44 | return result; | |||
|
45 | } | |||
|
46 | ||||
|
47 | ||||
|
48 | void vs10XXcmdwrite(vs10XXDev* dev,char address,int value) | |||
|
49 | { | |||
|
50 | while(!vs10XXDREQ()); | |||
|
51 | vs10XXclearXCS(); | |||
|
52 | spiputw(dev->SPIdev,(2<<8)+address); | |||
|
53 | spiputw(dev->SPIdev,value); | |||
|
54 | vs10XXsetXCS(); | |||
|
55 | } | |||
|
56 |
@@ -0,0 +1,14 | |||||
|
1 | TEMPLATE = lib | |||
|
2 | OBJECTS_DIR = obj | |||
|
3 | TARGET = vs10XX | |||
|
4 | ||||
|
5 | SOURCES += VS10XX.c | |||
|
6 | ||||
|
7 | ||||
|
8 | HEADERS += ../../../includes/VS10XX.h | |||
|
9 | ||||
|
10 | UCMODEL=stm32f4 | |||
|
11 | ||||
|
12 | target.path = $$[QT_INSTALL_LIBS]/$$UCMODEL | |||
|
13 | INSTALLS += target | |||
|
14 |
@@ -0,0 +1,103 | |||||
|
1 | /*------------------------------------------------------------------------------ | |||
|
2 | -- This file is a part of the libuc, microcontroler library | |||
|
3 | -- Copyright (C) 2011, Alexis Jeandet | |||
|
4 | -- | |||
|
5 | -- This program is free software; you can redistribute it and/or modify | |||
|
6 | -- it under the terms of the GNU General Public License as published by | |||
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |||
|
8 | -- (at your option) any later version. | |||
|
9 | -- | |||
|
10 | -- This program is distributed in the hope that it will be useful, | |||
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
|
13 | -- GNU General Public License for more details. | |||
|
14 | -- | |||
|
15 | -- You should have received a copy of the GNU General Public License | |||
|
16 | -- along with this program; if not, write to the Free Software | |||
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |||
|
18 | ------------------------------------------------------------------------------- | |||
|
19 | -- Author : Alexis Jeandet | |||
|
20 | -- Mail : alexis.jeandet@gmail.com | |||
|
21 | -------------------------------------------------------------------------------*/ | |||
|
22 | #include <24LC0X.h> | |||
|
23 | #include <i2c.h> | |||
|
24 | #include <core.h> | |||
|
25 | /* | |||
|
26 | struct 24LC0X_str | |||
|
27 | { | |||
|
28 | i2cDev iicdev; | |||
|
29 | unsigned char devAddress; | |||
|
30 | unsigned char size; | |||
|
31 | }; | |||
|
32 | */ | |||
|
33 | ||||
|
34 | ||||
|
35 | void eeprom24lc0xopen(eeprom24lc0xDev* dev, i2c_t iicdev, unsigned char A0_A1_A2_val, unsigned int size) | |||
|
36 | { | |||
|
37 | dev->iicdev = iicdev; | |||
|
38 | dev->devAddress = 0x50 | (A0_A1_A2_val & 0x7); | |||
|
39 | if(size == 2048) dev->size = 2; | |||
|
40 | if(size == 1024) dev->size = 1; | |||
|
41 | } | |||
|
42 | ||||
|
43 | void eeprom24lc0xpagewrite(eeprom24lc0xDev dev,unsigned char address,unsigned char* page) | |||
|
44 | { | |||
|
45 | int cmdcnt=1,datacnt=8; | |||
|
46 | //i2cwrite(dev.iicdev,address,page) | |||
|
47 | //i2cwrite2(dev.iicdev,dev.devAddress,&address,&cmdcnt,page,&datacnt); | |||
|
48 | } | |||
|
49 | ||||
|
50 | ||||
|
51 | void eeprom24lc0xpageread(eeprom24lc0xDev dev,unsigned char address,unsigned char* page) | |||
|
52 | { | |||
|
53 | int cmdcnt=1,datacnt=8; | |||
|
54 | /*i2cwrite(dev.iicdev,dev.devAddress,&address,&cmdcnt); | |||
|
55 | i2cread(dev.iicdev,dev.devAddress,page,&datacnt);*/ | |||
|
56 | } | |||
|
57 | ||||
|
58 | void eeprom24lc0xbytewrite(eeprom24lc0xDev dev,unsigned char address,unsigned char data) | |||
|
59 | { | |||
|
60 | int cmdcnt=1,datacnt=1; | |||
|
61 | //i2cwrite2(dev.iicdev,dev.devAddress,&address,&cmdcnt,&data,&datacnt); | |||
|
62 | } | |||
|
63 | ||||
|
64 | ||||
|
65 | unsigned char eeprom24lc0xbyteread(eeprom24lc0xDev dev,unsigned char address) | |||
|
66 | { | |||
|
67 | int cmdcnt=1,datacnt=1; | |||
|
68 | unsigned char data = 0; | |||
|
69 | /* i2cwrite(dev.iicdev,dev.devAddress,&address,&cmdcnt); | |||
|
70 | i2cread(dev.iicdev,dev.devAddress,&data,&datacnt);*/ | |||
|
71 | return data; | |||
|
72 | } | |||
|
73 | ||||
|
74 | ||||
|
75 | void eeprom24lc0xreadn(eeprom24lc0xDev dev,unsigned char address,unsigned char* data, unsigned int count) | |||
|
76 | { | |||
|
77 | int cmdcnt=1,datacnt=count; | |||
|
78 | /* i2cwrite(dev.iicdev,dev.devAddress,&address,&cmdcnt); | |||
|
79 | i2cread(dev.iicdev,dev.devAddress,data,&datacnt);*/ | |||
|
80 | ||||
|
81 | } | |||
|
82 | ||||
|
83 | void eeprom24lc0xwriten(eeprom24lc0xDev dev,unsigned char address,unsigned char* data, unsigned int count) | |||
|
84 | { | |||
|
85 | int cmdcnt=1,datacnt=8; | |||
|
86 | while(count >8) | |||
|
87 | { | |||
|
88 | cmdcnt=1;datacnt=8; | |||
|
89 | // while(i2noerr!=i2cwrite2(dev.iicdev,dev.devAddress,&address,&cmdcnt,data,&datacnt)){cmdcnt=1;datacnt=8;} | |||
|
90 | count-=8; | |||
|
91 | address+=8; | |||
|
92 | data+=8; | |||
|
93 | } | |||
|
94 | cmdcnt=1;datacnt=count; | |||
|
95 | // while(i2noerr!=i2cwrite2(dev.iicdev,dev.devAddress,&address,&cmdcnt,data,&datacnt)){cmdcnt=1;datacnt=count;} | |||
|
96 | } | |||
|
97 | ||||
|
98 | ||||
|
99 | ||||
|
100 | ||||
|
101 | ||||
|
102 | ||||
|
103 |
@@ -0,0 +1,15 | |||||
|
1 | TEMPLATE = lib | |||
|
2 | OBJECTS_DIR = obj | |||
|
3 | ||||
|
4 | SOURCES += 24LC0X.c | |||
|
5 | HEADERS += ../../../includes/24LC0X.h | |||
|
6 | ||||
|
7 | INCLUDEPATH += ../../../includes \ | |||
|
8 | ../../CPU/STM32F4xx_StdPeriph_Driver/inc \ | |||
|
9 | ../../CPU/CMSIS/Include | |||
|
10 | ||||
|
11 | ||||
|
12 | UCMODEL=stm32f4 | |||
|
13 | ||||
|
14 | target.path = $$[QT_INSTALL_LIBS]/$$UCMODEL | |||
|
15 | INSTALLS += target |
@@ -0,0 +1,136 | |||||
|
1 | /*------------------------------------------------------------------------------ | |||
|
2 | -- This file is a part of the libuc, microcontroler library | |||
|
3 | -- Copyright (C) 2013, Alexis Jeandet | |||
|
4 | -- | |||
|
5 | -- This program is free software; you can redistribute it and/or modify | |||
|
6 | -- it under the terms of the GNU General Public License as published by | |||
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |||
|
8 | -- (at your option) any later version. | |||
|
9 | -- | |||
|
10 | -- This program is distributed in the hope that it will be useful, | |||
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
|
13 | -- GNU General Public License for more details. | |||
|
14 | -- | |||
|
15 | -- You should have received a copy of the GNU General Public License | |||
|
16 | -- along with this program; if not, write to the Free Software | |||
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |||
|
18 | ------------------------------------------------------------------------------- | |||
|
19 | -- Author : Alexis Jeandet | |||
|
20 | -- Mail : alexis.jeandet@gmail.com | |||
|
21 | -------------------------------------------------------------------------------*/ | |||
|
22 | #include <N25Q128.h> | |||
|
23 | #include <core.h> | |||
|
24 | #include <stdio.h> | |||
|
25 | ||||
|
26 | ||||
|
27 | ||||
|
28 | void eepromN25Q128open(eepromN25Q128Dev *dev, spi_t spidev, void (*select)(int), void (*writeprotect)(int), void (*holdreset)(int)) | |||
|
29 | { | |||
|
30 | dev->spidev = spidev; | |||
|
31 | dev->holdreset = holdreset; | |||
|
32 | dev->select = select; | |||
|
33 | dev->writeprotect = writeprotect; | |||
|
34 | } | |||
|
35 | ||||
|
36 | void eepromN25Q128pagewrite(eepromN25Q128Dev* dev,uint32_t address,unsigned char* page) | |||
|
37 | { | |||
|
38 | int cmdcnt=1,datacnt=8; | |||
|
39 | } | |||
|
40 | ||||
|
41 | ||||
|
42 | void eepromN25Q128pageread(eepromN25Q128Dev* dev,uint32_t address,unsigned char* page) | |||
|
43 | { | |||
|
44 | int cmdcnt=1,datacnt=8; | |||
|
45 | } | |||
|
46 | ||||
|
47 | void eepromN25Q128bytewrite(eepromN25Q128Dev* dev,uint32_t address,unsigned char data) | |||
|
48 | { | |||
|
49 | int cmdcnt=1,datacnt=1; | |||
|
50 | } | |||
|
51 | ||||
|
52 | ||||
|
53 | unsigned char eepromN25Q128byteread(eepromN25Q128Dev* dev,uint32_t address) | |||
|
54 | { | |||
|
55 | int cmdcnt=1,datacnt=1; | |||
|
56 | unsigned char data = 0; | |||
|
57 | return data; | |||
|
58 | } | |||
|
59 | ||||
|
60 | ||||
|
61 | void eepromN25Q128readn(eepromN25Q128Dev* dev,uint32_t address,unsigned char* data, unsigned int count) | |||
|
62 | { | |||
|
63 | ||||
|
64 | char baddress[3]; | |||
|
65 | baddress[0]=(char)0xFF&((address)>>16); | |||
|
66 | baddress[1]=(char)0xFF&((address)>>8); | |||
|
67 | baddress[2]=(char)0xFF&((address)); | |||
|
68 | printf("about to read %d bytes\n\r",count); | |||
|
69 | if(dev->select!=NULL)dev->select(0); | |||
|
70 | spiputw(dev->spidev,N25Q128_READ); | |||
|
71 | spiputnc(dev->spidev,baddress,3); | |||
|
72 | spigetnc(dev->spidev,data,count); | |||
|
73 | if(dev->select!=NULL)dev->select(1); | |||
|
74 | ||||
|
75 | } | |||
|
76 | ||||
|
77 | void eepromN25Q128writen(eepromN25Q128Dev* dev,uint32_t address,unsigned char* data, unsigned int count) | |||
|
78 | { | |||
|
79 | char baddress[3]; | |||
|
80 | if(dev->select!=NULL)dev->select(0); | |||
|
81 | for(int i=0;i<(count/N25Q128_PAGE_SZ);i++) | |||
|
82 | { | |||
|
83 | printf("about to send %d bytes\n\r",N25Q128_PAGE_SZ); | |||
|
84 | int index =i*N25Q128_PAGE_SZ; | |||
|
85 | baddress[0]=(char)0xFF&((address+index)>>16); | |||
|
86 | baddress[1]=(char)0xFF&((address+index)>>8); | |||
|
87 | baddress[2]=(char)0xFF&((address+index)); | |||
|
88 | if(dev->select!=NULL)dev->select(0); | |||
|
89 | spiputw(dev->spidev,N25Q128_PP); | |||
|
90 | spiputnc(dev->spidev,baddress,3); | |||
|
91 | spiputnc(dev->spidev,data+(index),count); | |||
|
92 | if(dev->select!=NULL) | |||
|
93 | { | |||
|
94 | dev->select(1); | |||
|
95 | } | |||
|
96 | else { | |||
|
97 | while (!spitransactionfinished(dev->spidev)); | |||
|
98 | } | |||
|
99 | } | |||
|
100 | int mod = count%N25Q128_PAGE_SZ; | |||
|
101 | if(mod) | |||
|
102 | { | |||
|
103 | baddress[0]=(char)0xFF&((address+(count-mod))>>16); | |||
|
104 | baddress[1]=(char)0xFF&((address+(count-mod))>>8); | |||
|
105 | baddress[2]=(char)0xFF&((address+(count-mod))); | |||
|
106 | printf("about to send %d bytes\n\r",mod); | |||
|
107 | if(dev->select!=NULL)dev->select(0); | |||
|
108 | spiputw(dev->spidev,N25Q128_PP); | |||
|
109 | spiputnc(dev->spidev,baddress,3); | |||
|
110 | spiputnc(dev->spidev,data+(count-mod),mod); | |||
|
111 | if(dev->select!=NULL) | |||
|
112 | { | |||
|
113 | dev->select(1); | |||
|
114 | } | |||
|
115 | else { | |||
|
116 | while (!spitransactionfinished(dev->spidev)); | |||
|
117 | } | |||
|
118 | ||||
|
119 | } | |||
|
120 | ||||
|
121 | } | |||
|
122 | ||||
|
123 | ||||
|
124 | void eepromN25Q128enablewrite(eepromN25Q128Dev *dev) | |||
|
125 | { | |||
|
126 | if(dev->select!=NULL)dev->select(0); | |||
|
127 | spiputw(dev->spidev,N25Q128_WREN); | |||
|
128 | if(dev->select!=NULL)dev->select(1); | |||
|
129 | ||||
|
130 | } | |||
|
131 | ||||
|
132 | ||||
|
133 | ||||
|
134 | ||||
|
135 | ||||
|
136 |
@@ -0,0 +1,15 | |||||
|
1 | TEMPLATE = lib | |||
|
2 | OBJECTS_DIR = obj | |||
|
3 | ||||
|
4 | SOURCES += N25Q128.c | |||
|
5 | HEADERS += ../../../includes/N25Q128.h | |||
|
6 | ||||
|
7 | INCLUDEPATH += ../../../includes \ | |||
|
8 | ../../CPU/STM32F4xx_StdPeriph_Driver/inc \ | |||
|
9 | ../../CPU/CMSIS/Include | |||
|
10 | ||||
|
11 | ||||
|
12 | UCMODEL=stm32f4 | |||
|
13 | ||||
|
14 | target.path = $$[QT_INSTALL_LIBS]/$$UCMODEL | |||
|
15 | INSTALLS += target |
@@ -0,0 +1,74 | |||||
|
1 | /*------------------------------------------------------------------------------ | |||
|
2 | -- This file is a part of the libuc, microcontroler library | |||
|
3 | -- Copyright (C) 2013, Alexis Jeandet | |||
|
4 | -- | |||
|
5 | -- This program is free software; you can redistribute it and/or modify | |||
|
6 | -- it under the terms of the GNU General Public License as published by | |||
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |||
|
8 | -- (at your option) any later version. | |||
|
9 | -- | |||
|
10 | -- This program is distributed in the hope that it will be useful, | |||
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
|
13 | -- GNU General Public License for more details. | |||
|
14 | -- | |||
|
15 | -- You should have received a copy of the GNU General Public License | |||
|
16 | -- along with this program; if not, write to the Free Software | |||
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |||
|
18 | ------------------------------------------------------------------------------- | |||
|
19 | -- Author : Alexis Jeandet | |||
|
20 | -- Mail : alexis.jeandet@gmail.com | |||
|
21 | -------------------------------------------------------------------------------*/ | |||
|
22 | #ifndef N25Q128_H | |||
|
23 | #define N25Q128_H | |||
|
24 | ||||
|
25 | #include <spi.h> | |||
|
26 | #include <uhandle.h> | |||
|
27 | #include <stdint.h> | |||
|
28 | ||||
|
29 | typedef struct eepromN25Q128Dev | |||
|
30 | { | |||
|
31 | spi_t spidev; | |||
|
32 | void (*select)(int sel); | |||
|
33 | void (*writeprotect)(int wp); | |||
|
34 | void (*holdreset)(int hr); | |||
|
35 | }eepromN25Q128Dev; | |||
|
36 | ||||
|
37 | #define N25Q128_PAGE_SZ 256 | |||
|
38 | ||||
|
39 | #define N25Q128_READID 0x9E | |||
|
40 | #define N25Q128_READ 0x03 | |||
|
41 | #define N25Q128_FASTREAD 0x0B | |||
|
42 | #define N25Q128_DOFR 0x3B | |||
|
43 | #define N25Q128_DIOFR 0xBB | |||
|
44 | #define N25Q128_QOFR 0x6B | |||
|
45 | #define N25Q128_QIOFR 0xEB | |||
|
46 | #define N25Q128_ROTP 0x4B | |||
|
47 | #define N25Q128_WREN 0x06 | |||
|
48 | #define N25Q128_WRDI 0x04 | |||
|
49 | #define N25Q128_PP 0x02 | |||
|
50 | ||||
|
51 | ||||
|
52 | ||||
|
53 | ||||
|
54 | ||||
|
55 | extern void eepromN25Q128open(eepromN25Q128Dev* dev,spi_t spidev,void (*select)(int sel),void (*writeprotect)(int wp),void (*holdreset)(int hr)); | |||
|
56 | extern void eepromN25Q128pagewrite(eepromN25Q128Dev* dev,uint32_t address,unsigned char* page); | |||
|
57 | extern void eepromN25Q128pageread(eepromN25Q128Dev* dev,uint32_t address,unsigned char* page); | |||
|
58 | extern void eepromN25Q128bytewrite(eepromN25Q128Dev* dev,uint32_t address,unsigned char data); | |||
|
59 | extern unsigned char eepromN25Q128byteread(eepromN25Q128Dev* dev,uint32_t address); | |||
|
60 | extern void eepromN25Q128readn(eepromN25Q128Dev* dev,uint32_t address,unsigned char* data, unsigned int count); | |||
|
61 | extern void eepromN25Q128writen(eepromN25Q128Dev* dev,uint32_t address,unsigned char* data, unsigned int count); | |||
|
62 | extern void eepromN25Q128enablewrite(eepromN25Q128Dev* dev); | |||
|
63 | ||||
|
64 | ||||
|
65 | ||||
|
66 | ||||
|
67 | #endif | |||
|
68 | ||||
|
69 | ||||
|
70 | ||||
|
71 | ||||
|
72 | ||||
|
73 | ||||
|
74 |
@@ -0,0 +1,78 | |||||
|
1 | /*------------------------------------------------------------------------------ | |||
|
2 | #-- This file is a part of the libuc, microcontroler library | |||
|
3 | #-- Copyright (C) 2011, Alexis Jeandet | |||
|
4 | #-- | |||
|
5 | #-- This program is free software; you can redistribute it and/or modify | |||
|
6 | #-- it under the terms of the GNU General Public License as published by | |||
|
7 | #-- the Free Software Foundation; either version 3 of the License, or | |||
|
8 | #-- (at your option) any later version. | |||
|
9 | #-- | |||
|
10 | #-- This program is distributed in the hope that it will be useful, | |||
|
11 | #-- but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
|
12 | #-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
|
13 | #-- GNU General Public License for more details. | |||
|
14 | #-- | |||
|
15 | #-- You should have received a copy of the GNU General Public License | |||
|
16 | #-- along with this program; if not, write to the Free Software | |||
|
17 | #-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |||
|
18 | #------------------------------------------------------------------------------- | |||
|
19 | #-- Author : Alexis Jeandet | |||
|
20 | #-- Mail : alexis.jeandet@gmail.com | |||
|
21 | #-------------------------------------------------------------------------------*/ | |||
|
22 | #ifndef VS10XX_H | |||
|
23 | #define VS10XX_H | |||
|
24 | #include <uhandle.h> | |||
|
25 | #include <spi.h> | |||
|
26 | ||||
|
27 | #define VSMODE 0 | |||
|
28 | #define VSSTATUS 1 | |||
|
29 | #define VSBASS 2 | |||
|
30 | #define VSCLOCKF 3 | |||
|
31 | #define VSDECODE_TIME 4 | |||
|
32 | #define VSAUDATA 5 | |||
|
33 | #define VSWRAM 6 | |||
|
34 | #define VSWRAMADDR 7 | |||
|
35 | #define VSHDAT0 8 | |||
|
36 | #define VSHDAT1 9 | |||
|
37 | #define VSAIADDR 0xA | |||
|
38 | #define VSVOL 0xB | |||
|
39 | #define VSAICTRL0 0xC | |||
|
40 | #define VSAICTRL1 0xD | |||
|
41 | #define VSAICTRL2 0xE | |||
|
42 | #define VSAICTRL3 0xF | |||
|
43 | ||||
|
44 | typedef struct vs10XXDev | |||
|
45 | { | |||
|
46 | spi_t SPIdev; | |||
|
47 | int a; | |||
|
48 | }vs10XXDev; | |||
|
49 | ||||
|
50 | ||||
|
51 | void vs10XXopen(vs10XXDev* codec,spi_t dev); | |||
|
52 | void vs10XXsoftreset(vs10XXDev* dev); | |||
|
53 | int vs10XXcmdread(vs10XXDev* dev,char address); | |||
|
54 | void vs10XXcmdwrite(vs10XXDev* dev,char address,int value); | |||
|
55 | ||||
|
56 | extern void vs10XXclearXCS(); | |||
|
57 | extern void vs10XXsetXCS(); | |||
|
58 | extern int vs10XXDREQ(); | |||
|
59 | ||||
|
60 | #endif //VS10XX_H | |||
|
61 | ||||
|
62 | ||||
|
63 | ||||
|
64 | ||||
|
65 | ||||
|
66 | ||||
|
67 | ||||
|
68 | ||||
|
69 | ||||
|
70 | ||||
|
71 | ||||
|
72 | ||||
|
73 | ||||
|
74 | ||||
|
75 | ||||
|
76 | ||||
|
77 | ||||
|
78 |
@@ -26,8 +26,8 | |||||
26 | #include <stm32f4xx_rcc.h> |
|
26 | #include <stm32f4xx_rcc.h> | |
27 | #include <gpio.h> |
|
27 | #include <gpio.h> | |
28 |
|
28 | |||
29 |
#define __MAX_OPENED_FILES__ |
|
29 | #define __MAX_OPENED_FILES__ 32 | |
30 |
#define __FS_ROOT_SIZE__ |
|
30 | #define __FS_ROOT_SIZE__ 32 | |
31 | /* |
|
31 | /* | |
32 | #ifndef PD8 |
|
32 | #ifndef PD8 | |
33 | #define PD8 |
|
33 | #define PD8 | |
@@ -42,15 +42,6 | |||||
42 | #define LED3 PD14 |
|
42 | #define LED3 PD14 | |
43 | #define LED4 PD15 |
|
43 | #define LED4 PD15 | |
44 |
|
44 | |||
45 |
|
||||
46 | #define LED3ON GPIOB->BSRRH = GPIO_Pin_15 |
|
|||
47 | #define LED2ON GPIOD->BSRRH = GPIO_Pin_8 |
|
|||
48 | #define LED1ON GPIOD->BSRRH = GPIO_Pin_9 |
|
|||
49 |
|
||||
50 | #define LED3OFF GPIOB->BSRRL = GPIO_Pin_15 |
|
|||
51 | #define LED2OFF GPIOD->BSRRL = GPIO_Pin_8 |
|
|||
52 | #define LED1OFF GPIOD->BSRRL = GPIO_Pin_9 |
|
|||
53 |
|
||||
54 | extern float VREF0; |
|
45 | extern float VREF0; | |
55 |
|
46 | |||
56 | extern uint32_t currentCpuFreq; |
|
47 | extern uint32_t currentCpuFreq; |
@@ -9,7 +9,8 SUBDIRS += QtTest/test.pro \ | |||||
9 | BeagleSynthHello \ |
|
9 | BeagleSynthHello \ | |
10 | lcdTerminal \ |
|
10 | lcdTerminal \ | |
11 | BeagleSynthHelloSupMon \ |
|
11 | BeagleSynthHelloSupMon \ | |
12 | TEST_CMSIS_FFT |
|
12 | TEST_CMSIS_FFT \ | |
|
13 | N25Q128_test | |||
13 |
|
14 | |||
14 |
|
15 | |||
15 |
|
16 |
@@ -1,5 +1,5 | |||||
1 | TEMPLATE = subdirs |
|
1 | TEMPLATE = subdirs | |
2 | CONFIG += ordered |
|
2 | CONFIG += ordered | |
3 |
|
3 | |||
4 |
SUBDIRS += CS43L22 |
|
4 | SUBDIRS += CS43L22 \ | |
5 |
|
|
5 | VS10XX |
@@ -4,7 +4,8 SUBDIRS += FILE_SYSTEM \ | |||||
4 | AUDIO \ |
|
4 | AUDIO \ | |
5 | POWER \ |
|
5 | POWER \ | |
6 | GRAPHIC \ |
|
6 | GRAPHIC \ | |
7 |
|
|
7 | Threading \ | |
|
8 | EEPROMS | |||
8 |
|
9 | |||
9 |
|
10 | |||
10 |
|
11 | |||
@@ -12,3 +13,4 SUBDIRS += FILE_SYSTEM \ | |||||
12 |
|
13 | |||
13 |
|
14 | |||
14 |
|
15 | |||
|
16 |
@@ -22,20 +22,19 | |||||
22 | #ifndef B24LC0X_H |
|
22 | #ifndef B24LC0X_H | |
23 | #define B24LC0X_H |
|
23 | #define B24LC0X_H | |
24 |
|
24 | |||
25 |
#include |
|
25 | #include <i2c.h> | |
26 | #include <uhandle.h> |
|
26 | #include <uhandle.h> | |
27 |
|
27 | |||
28 |
struct eeprom24 |
|
28 | typedef struct eeprom24lc0xDev | |
29 | { |
|
29 | { | |
30 |
i2c |
|
30 | i2c_t iicdev; | |
31 | unsigned char devAddress; |
|
31 | unsigned char devAddress; | |
32 | unsigned char size; |
|
32 | unsigned char size; | |
33 | }; |
|
33 | }eeprom24lc0xDev; | |
34 |
|
||||
35 | typedef struct eeprom24LC0X_str eeprom24lc0xDev; |
|
|||
36 |
|
34 | |||
37 |
|
35 | |||
38 | extern void eeprom24lc0xopen(eeprom24lc0xDev* dev,i2cDev iicdev,unsigned char A0_A1_A2_val,unsigned int size); |
|
36 | ||
|
37 | extern void eeprom24lc0xopen(eeprom24lc0xDev* dev,i2c_t iicdev,unsigned char A0_A1_A2_val,unsigned int size); | |||
39 |
|
38 | |||
40 | extern void eeprom24lc0xpagewrite(eeprom24lc0xDev dev,unsigned char address,unsigned char* page); |
|
39 | extern void eeprom24lc0xpagewrite(eeprom24lc0xDev dev,unsigned char address,unsigned char* page); | |
41 | extern void eeprom24lc0xpageread(eeprom24lc0xDev dev,unsigned char address,unsigned char* page); |
|
40 | extern void eeprom24lc0xpageread(eeprom24lc0xDev dev,unsigned char address,unsigned char* page); |
@@ -44,15 +44,15 typedef struct spi_t | |||||
44 |
|
44 | |||
45 | typedef int spi_t; |
|
45 | typedef int spi_t; | |
46 |
|
46 | |||
47 | #define spi1 0 |
|
47 | #define spi1 ((spi_t)0) | |
48 | #define spi2 1 |
|
48 | #define spi2 ((spi_t)1) | |
49 | #define spi3 2 |
|
49 | #define spi3 ((spi_t)2) | |
50 | #define spi4 3 |
|
50 | #define spi4 ((spi_t)3) | |
51 | #define spi5 4 |
|
51 | #define spi5 ((spi_t)4) | |
52 | #define spi6 5 |
|
52 | #define spi6 ((spi_t)5) | |
53 | #define spi7 6 |
|
53 | #define spi7 ((spi_t)6) | |
54 | #define spi8 7 |
|
54 | #define spi8 ((spi_t)7) | |
55 | #define spi9 8 |
|
55 | #define spi9 ((spi_t)8) | |
56 |
|
56 | |||
57 |
|
57 | |||
58 | typedef enum |
|
58 | typedef enum | |
@@ -114,6 +114,7 extern int spiclose(spi_t spidev); | |||||
114 | extern int spisetpins(spi_t spidev,uint32_t MOSIpin,uint32_t MISOpin,uint32_t SCKpin,uint32_t SCSpin); |
|
114 | extern int spisetpins(spi_t spidev,uint32_t MOSIpin,uint32_t MISOpin,uint32_t SCKpin,uint32_t SCSpin); | |
115 | extern int spienable(spi_t spidev); |
|
115 | extern int spienable(spi_t spidev); | |
116 | extern int spidisable(spi_t spidev); |
|
116 | extern int spidisable(spi_t spidev); | |
|
117 | extern int spitransactionfinished(spi_t spidev); | |||
117 | extern int spisetconfig(spi_t spidev,uint32_t config,uint32_t speed); |
|
118 | extern int spisetconfig(spi_t spidev,uint32_t config,uint32_t speed); | |
118 | extern int spisetspeed(spi_t spidev, uint32_t speed); |
|
119 | extern int spisetspeed(spi_t spidev, uint32_t speed); | |
119 | extern int spisetbitorder(spi_t spidev,spibitorder_t order); |
|
120 | extern int spisetbitorder(spi_t spidev,spibitorder_t order); |
@@ -352,7 +352,7 uint16_t spigetw(spi_t spidev) | |||||
352 | SPI_TypeDef* _dev_ = _spi_dev_table[(int)spidev]; |
|
352 | SPI_TypeDef* _dev_ = _spi_dev_table[(int)spidev]; | |
353 | while((_dev_->SR & (1<<7)) == (1<<7)); |
|
353 | while((_dev_->SR & (1<<7)) == (1<<7)); | |
354 | _dev_->DR = 0xFFFF; |
|
354 | _dev_->DR = 0xFFFF; | |
355 | while((_dev_->SR & (1<<0)) == 0); |
|
355 | while(((_dev_->SR & (1<<0)) == 0) || (_dev_->SR & (1<<7)) == (1<<7)); | |
356 | return _dev_->DR; |
|
356 | return _dev_->DR; | |
357 | } |
|
357 | } | |
358 | return -1; |
|
358 | return -1; | |
@@ -420,6 +420,15 int spiavailiabledata(spi_t spidev) | |||||
420 | } |
|
420 | } | |
421 |
|
421 | |||
422 |
|
422 | |||
|
423 | int spitransactionfinished(spi_t spidev) | |||
|
424 | { | |||
|
425 | SPI_TypeDef* _dev_ = _spi_dev_table[(int)spidev]; | |||
|
426 | if((spidev<3)&&(spidev>=0)) | |||
|
427 | { | |||
|
428 | if((_dev_->SR & (1<<7)) == (1<<7))return 1; | |||
|
429 | } | |||
|
430 | return 0; | |||
|
431 | } | |||
423 |
|
432 | |||
424 |
|
433 | |||
425 |
|
434 | |||
@@ -435,3 +444,5 int spiavailiabledata(spi_t spidev) | |||||
435 |
|
444 | |||
436 |
|
445 | |||
437 |
|
446 | |||
|
447 | ||||
|
448 |
@@ -3,6 +3,8 OBJECTS_DIR = obj | |||||
3 |
|
3 | |||
4 | SOURCES += spi.c |
|
4 | SOURCES += spi.c | |
5 |
|
5 | |||
|
6 | HEADERS += ../../includes/spi.h | |||
|
7 | ||||
6 | INCLUDEPATH += ../../includes \ |
|
8 | INCLUDEPATH += ../../includes \ | |
7 | ../CPU/STM32F4xx_StdPeriph_Driver/inc \ |
|
9 | ../CPU/STM32F4xx_StdPeriph_Driver/inc \ | |
8 | ../CPU/CMSIS/Include |
|
10 | ../CPU/CMSIS/Include |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now