1 /* -------------------------------- Arctic Core ------------------------------
\r
2 * Arctic Core - the open source AUTOSAR platform http://arccore.com
\r
4 * Copyright (C) 2009 ArcCore AB <contact@arccore.com>
\r
6 * This source code is free software; you can redistribute it and/or modify it
\r
7 * under the terms of the GNU General Public License version 2 as published by the
\r
8 * Free Software Foundation; See <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>.
\r
10 * This program is distributed in the hope that it will be useful, but
\r
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
\r
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
\r
14 * -------------------------------- Arctic Core ------------------------------*/
\r
23 #warning "This default file may only be used as an example!"
\r
29 #include "mpc55xx.h"
\r
32 #define DSPI_CTRL_A 0
\r
33 #define DSPI_CTRL_B 1
\r
34 #define DSPI_CTRL_C 2
\r
35 #define DSPI_CTRL_D 3
\r
38 * General configuration
\r
41 // Maximum amount of data that can be written/read in one go.
\r
42 #define SPI_EB_MAX_LENGTH 64
\r
44 // Switches the Spi_Cancel function ON or OFF.
\r
45 #define SPI_CANCEL_API STD_OFF
\r
47 // Selects the SPI Handler/Driver Channel Buffers usage allowed and delivered.
\r
48 // LEVEL 0 - Only Internal buffers
\r
49 // LEVEL 1 - Only external buffers
\r
50 // LEVEL 2 - Both internal/external buffers
\r
51 #define SPI_CHANNEL_BUFFERS_ALLOWED 1
\r
53 #define SPI_DEV_ERROR_DETECT STD_ON
\r
54 // Switches the Spi_GetHWUnitStatus function ON or OFF.
\r
55 #define SPI_HW_STATUS_API STD_ON
\r
56 // Switches the Interruptible Sequences handling functionality ON or OFF.
\r
57 #define SPI_INTERRUPTIBLE_SEQ_ALLOWED STD_OFF
\r
59 // LEVEL 0 - Simple sync
\r
60 // LEVEL 1 - Basic async
\r
61 // LEVEL 2 - Enhanced mode
\r
62 #define SPI_LEVEL_DELIVERED 2
\r
64 #define SPI_VERSION_INFO_API STD_ON
\r
67 #if SPI_LEVEL_DELIVERED>=1
\r
68 #define SPI_INTERRUPTIBLE_SEQ_ALLOWED STD_ON
\r
73 #define E2_WREN 0x6 // Write Enable 0000 0110
\r
74 #define E2_WRDI 0x4 // Write Disable 0000 0100
\r
75 #define E2_RDSR 0x5 // Read Status Register 0000 0101
\r
77 #define E2_WRSR 0x1 // Write Status Register 0000 0001
\r
79 #define E2_READ 0x3 // Read from Memory Array 0000 0011
\r
80 // 1 - Write 16-bit address
\r
81 // n - 8 -bit read data
\r
82 #define E2_WRITE 0x2 // WRITE Write to Memory Array 0000 0010
\r
83 // 1 Write 16-bit address
\r
87 #define FLASH_READ_25 0x03
\r
88 #define FLASH_READ_50 0x0B
\r
89 #define FLASH_RDSR 0x05
\r
90 #define FLASH_JEDEC_ID 0x9f
\r
91 #define FLASH_RDID 0x90
\r
92 #define FLASH_BYTE_WRITE 0x02
\r
93 #define FLASH_AI_WORD_WRITE 0xad
\r
94 #define FLASH_WREN 0x06
\r
95 #define FLASH_WRDI 0x04
\r
96 #define FLASH_WRSR 0x01
\r
97 #define FLASH_ERASE_4K 0x20
\r
103 SPI_EB = 0, // External Buffer
\r
104 SPI_IB // Internal Buffer
\r
108 SPI_EXT_DEVICE_A_E2,
\r
109 SPI_EXT_DEVICE_A_FLASH,
\r
110 SPI_EXT_DEVICE_B_E2,
\r
111 } Spi_ExternalDeviceTypeType;
\r
137 SPI_JOB_E2_CMD = 0,
\r
148 SPI_JOB_FLASH_CMD2,
\r
149 SPI_JOB_FLASH_CMD_DATA,
\r
150 SPI_JOB_FLASH_READ,
\r
151 SPI_JOB_FLASH_WREN,
\r
152 SPI_JOB_FLASH_WRDI,
\r
153 SPI_JOB_FLASH_DATA,
\r
154 SPI_JOB_FLASH_WRSR,
\r
155 SPI_JOB_FLASH_ADDR,
\r
160 #define SPI_MAX_CHANNELS 8
\r
164 SPI_SEQ_E2_CMD = 0,
\r
175 SPI_SEQ_FLASH_CMD2,
\r
176 SPI_SEQ_FLASH_CMD_DATA,
\r
177 SPI_SEQ_FLASH_READ,
\r
178 SPI_SEQ_FLASH_WRITE,
\r
179 SPI_SEQ_FLASH_WRSR,
\r
180 SPI_SEQ_FLASH_ERASE,
\r
183 } Spi_SequenceType;
\r
187 SPI_ARC_TRANSFER_START_LSB,
\r
188 SPI_ARC_TRANSFER_START_MSB,
\r
189 } Spi_Arc_TransferStartType;
\r
199 // All data needed to configure one SPI-channel
\r
203 Spi_ChannelType SpiChannelId;
\r
204 // Buffer usage with EB/IB channel
\r
205 // TODO: The type is wrong...
\r
206 unsigned SpiChannelType;
\r
208 // This parameter is the width of a transmitted data unit.
\r
209 uint32 SpiDataWidth;
\r
210 // This parameter is the default value to transmit.
\r
211 uint32 SpiDefaultData;
\r
213 // This parameter contains the maximum size of data buffers in case of EB
\r
214 // Channels and only.
\r
215 Spi_NumberOfDataType SpiEbMaxLength;
\r
217 // This parameter contains the maximum number of data buffers in case of IB
\r
218 // Channels and only.
\r
219 Spi_NumberOfDataType SpiIbNBuffers;
\r
221 // This parameter defines the first starting bit for transmission.
\r
222 Spi_Arc_TransferStartType SpiTransferStart;
\r
225 _Bool SpiDmaNoIncreaseSrc;
\r
227 } Spi_ChannelConfigType;
\r
229 // All data needed to configure one SPI-Job, amongst others the connection
\r
230 // between the internal SPI unit and the special settings for an external de-
\r
235 Spi_JobType SpiJobId;
\r
237 // This parameter is the symbolic name to identify the HW SPI Hardware micro-
\r
238 // controller peripheral allocated to this Job.
\r
241 // This parameter is a reference to a notification function.
\r
242 void (*SpiJobEndNotification)();
\r
244 // Priority of the Job
\r
246 unsigned SpiJobPriority;
\r
248 // A job references several channels.
\r
249 uint32 ChannelAssignment[SPI_MAX_CHANNELS];
\r
251 // Reference to the external device used by this job
\r
252 Spi_ExternalDeviceTypeType DeviceAssignment;
\r
254 // unsigned SPI_NUMBER_OF_CHANNELS;
\r
255 // unsigned SPI_LIST_OF_CHANNELS[SPI_MAX_CHANNEL];
\r
256 } Spi_JobConfigType;
\r
258 // The communication settings of an external device. Closely linked to Spi-
\r
263 // This parameter is the communication baudrate - This parameter allows
\r
264 // using a range of values, from the point of view of configuration tools, from
\r
266 // Note! Float in config case, not here
\r
267 uint32 SpiBaudrate;
\r
269 // Symbolic name to identify the CS used for this job
\r
270 uint32 SpiCsIdentifier;
\r
272 // This parameter defines the active polarity of Chip Select.
\r
273 // STD_HIGH or STD_LOW
\r
274 uint8 SpiCsPolarity;
\r
276 // This parameter defines the SPI data shift edge.
\r
277 Spi_EdgeType SpiDataShiftEdge;
\r
279 // This parameter enables or not the Chip Select handling functions.
\r
282 // This parameter defines the SPI shift clock idle level.
\r
283 uint8 SpiShiftClockIdleLevel;
\r
285 // Timing between clock and chip select - This parameter allows to use a
\r
286 // range of values from 0 up to 100 microSec. the real configuration-value
\r
287 // used in software BSW-SPI is calculated out of this by the generator-tools
\r
288 // Note! Float in config case, not here. Unit ns
\r
289 uint32 SpiTimeClk2Cs;
\r
291 // Timing between PCS and first edge of SCK. Unit ns.
\r
292 uint32 SpiTimeCs2Clk;
\r
294 // ArcCore extension...
\r
295 // The controller ID(0..3)
\r
296 //uint32 SpiControllerId;
\r
298 } Spi_ExternalDeviceType;
\r
300 // All data needed to configure one SPI-sequence
\r
303 // This parameter allows or not this Sequence to be suspended by another
\r
305 unsigned SpiInterruptibleSequence;
\r
306 // This parameter is a reference to a notification function.
\r
307 void (*SpiSeqEndNotification)();
\r
309 Spi_SequenceType SpiSequenceId;
\r
310 // unsigned SPI_NUMBER_OF_JOBS;
\r
311 // A sequence references several jobs, which are executed during a commu-
\r
312 // nication sequence
\r
313 uint32 JobAssignment[SPI_MAX_JOB];
\r
314 } Spi_SequenceConfigType;
\r
318 /* Interrupt priority level for this SPI channel. */
\r
321 /* This channel is to be activated for use. */
\r
324 /* Receive DMA channel. */
\r
325 Dma_ChannelType RxDmaChannel;
\r
327 /* Transmit DMA channel. */
\r
328 Dma_ChannelType TxDmaChannel;
\r
330 /* Peripheral clock source. */
\r
331 McuE_PeriperalClock_t PeripheralClock;
\r
336 // This parameter contains the number of Channels configured. It will be
\r
337 // gathered by tools during the configuration stage.
\r
338 uint8 SpiMaxChannel;
\r
342 uint8 SpiMaxSequence;
\r
344 // All data needed to configure one SPI-channel
\r
345 const Spi_ChannelConfigType * SpiChannelConfig;
\r
347 // The communication settings of an external device. Closely
\r
348 // linked to SpiJob.
\r
349 const Spi_ExternalDeviceType * SpiExternalDevice;
\r
351 // All data needed to configure one SPI-Job, amongst others the
\r
352 // connection between the internal SPI unit and the special set-
\r
353 // tings for an external device is done.
\r
354 const Spi_JobConfigType * SpiJobConfig;
\r
356 // All data needed to configure one SPI-sequence
\r
357 const Spi_SequenceConfigType * SpiSequenceConfig;
\r
359 const Spi_HwConfigType *SpiHwConfig;
\r
362 typedef Spi_DriverType Spi_ConfigType;
\r
366 struct SpiDriverConfiguration_s
\r
368 Spi_ChannelType SPI_MAX_CHANNEL;
\r
369 Spi_JobType SPI_MAX_JOB;
\r
370 Spi_SequenceType SPI_MAX_SEQUENCE;
\r
374 // This is implementation specific but not all values may be valid
\r
375 // within the type.This type shall be chosen in order to have the
\r
376 // most efficient implementation on a specific microcontroller
\r
378 // In-short: Type of application data buffer elements
\r
379 // The 5516 TXDATA is 16-bit.. fits ?
\r
381 typedef uint8 Spi_DataType;
\r
382 //typedef uint16 Spi_DataType;
\r
384 // Specifies the identification (ID) for a SPI Hardware microcontroller peripheral (unit).
\r
385 // SPI140: This type is configurable (On / Off) at pre-compile time. The switch
\r
386 // SPI_HW_STATUS_API shall activate or deactivate the declaration of this
\r
388 typedef uint32 Spi_HWUnitType;
\r
393 Spi_SequenceConfigType SpiSequenceConfig;
\r
394 Spi_JobConfigType SpiJobConfig;
\r
395 Spi_ChannelConfigType SpiChannelConfig;
\r
396 Spi_ExternalDeviceType SpiExternalDevice;
\r
400 extern const Spi_ConfigType SpiConfigData;
\r
403 uint32 Spi_GetJobCnt(void );
\r
404 uint32 Spi_GetChannelCnt(void );
\r
405 uint32 Spi_GetExternalDeviceCnt(void );
\r
409 #endif /*SPI_CFG_H_*/
\r