<commit_before>// Copyright Microsoft Corporation
// Copyright GHI Electronics, LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "AT91.h"

#define DEPLOYMENT_SECTOR_START                 640
#define DEPLOYMENT_SECTOR_END                   1020
#define DEPLOYMENT_SECTOR_NUM                   (DEPLOYMENT_SECTOR_END - DEPLOYMENT_SECTOR_START + 1)

#define COMMAND_READID                          0x9F
#define COMMAND_READ_STATUS_REGISTER            0xD7
#define COMMAND_WRITE_BUFFER_1                  0x84
#define COMMAND_WRITE_BUFFER_2                  0x87
#define COMMAND_WRITE_BUFFER_1_TO_MEMORY        0x83
#define COMMAND_WRITE_BUFFER_2_TO_MEMORY        0x86
#define COMMAND_READ_FROM_MAIN_MEMORY_LEGACY    0xE8
#define COMMAND_READ_FROM_MAIN_MEMORY_DIRECT    0xD2
#define COMMAND_PAGE_ERASE                      0x81

#define COMMAND_READ_STATUS_REGISTER            0xD7
#define COMMAND_WRITE_BUFFER_1                  0x84
#define COMMAND_WRITE_BUFFER_2                  0x87
#define COMMAND_WRITE_BUFFER_1_TO_MEMORY        0x83
#define COMMAND_WRITE_BUFFER_2_TO_MEMORY        0x86
#define COMMAND_READ_FROM_MAIN_MEMORY_LEGACY    0xE8
#define COMMAND_READ_FROM_MAIN_MEMORY_DIRECT    0xD2
#define COMMAND_PAGE_ERASE                      0x81
#define COMMAND_BLOCK_ERASE                     0x50

#define WRITE_COMMAND_SIZE                      4
#define FLASH_ACCESS_TIMEOUT                    1000 // 1000 ms

#define FLASH_PAGE_SIZE                         528
#define FLASH_BLOCK_SIZE                        (528 * 8)

//SPI config
#define SPI_CS                                   PIN(A,14)
#define SPI_CLOCK_RATE_HZ                        20000000
#define SPI_MODULE                               0// SPI0

#define FLASH_MANUFACTURER_CODE                 0x1F
#define FLASH_DEVICE_CODE                       0x27 // For 4MB Chip


static uint32_t deploymentAddress[DEPLOYMENT_SECTOR_NUM];
static uint32_t deploymentSize[DEPLOYMENT_SECTOR_NUM];

uint8_t AT91_Flash_BufferRW[(FLASH_PAGE_SIZE * 1) + WRITE_COMMAND_SIZE];

static TinyCLR_Deployment_Provider deploymentProvider;
static TinyCLR_Api_Info deploymentApi;

struct AT91_Flash_Controller {
    uint8_t dataReadBuffer[FLASH_BLOCK_SIZE + 8];
    uint8_t dataWriteBuffer[FLASH_BLOCK_SIZE + 8];

    TinyCLR_Spi_Provider* provider;<commit_msg>Change CS pin<commit_after>// Copyright Microsoft Corporation
// Copyright GHI Electronics, LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "AT91.h"

#define DEPLOYMENT_SECTOR_START                 640
#define DEPLOYMENT_SECTOR_END                   1020
#define DEPLOYMENT_SECTOR_NUM                   (DEPLOYMENT_SECTOR_END - DEPLOYMENT_SECTOR_START + 1)

#define COMMAND_READID                          0x9F
#define COMMAND_READ_STATUS_REGISTER            0xD7
#define COMMAND_WRITE_BUFFER_1                  0x84
#define COMMAND_WRITE_BUFFER_2                  0x87
#define COMMAND_WRITE_BUFFER_1_TO_MEMORY        0x83
#define COMMAND_WRITE_BUFFER_2_TO_MEMORY        0x86
#define COMMAND_READ_FROM_MAIN_MEMORY_LEGACY    0xE8
#define COMMAND_READ_FROM_MAIN_MEMORY_DIRECT    0xD2
#define COMMAND_PAGE_ERASE                      0x81

#define COMMAND_READ_STATUS_REGISTER            0xD7
#define COMMAND_WRITE_BUFFER_1                  0x84
#define COMMAND_WRITE_BUFFER_2                  0x87
#define COMMAND_WRITE_BUFFER_1_TO_MEMORY        0x83
#define COMMAND_WRITE_BUFFER_2_TO_MEMORY        0x86
#define COMMAND_READ_FROM_MAIN_MEMORY_LEGACY    0xE8
#define COMMAND_READ_FROM_MAIN_MEMORY_DIRECT    0xD2
#define COMMAND_PAGE_ERASE                      0x81
#define COMMAND_BLOCK_ERASE                     0x50

#define WRITE_COMMAND_SIZE                      4
#define FLASH_ACCESS_TIMEOUT                    1000 // 1000 ms

#define FLASH_PAGE_SIZE                         528
#define FLASH_BLOCK_SIZE                        (528 * 8)

//SPI config
#define SPI_CS                                   PIN(A,28)
#define SPI_CLOCK_RATE_HZ                        20000000
#define SPI_MODULE                               0// SPI0

#define FLASH_MANUFACTURER_CODE                 0x1F
#define FLASH_DEVICE_CODE                       0x27 // For 4MB Chip


static uint32_t deploymentAddress[DEPLOYMENT_SECTOR_NUM];
static uint32_t deploymentSize[DEPLOYMENT_SECTOR_NUM];

uint8_t AT91_Flash_BufferRW[(FLASH_PAGE_SIZE * 1) + WRITE_COMMAND_SIZE];

static TinyCLR_Deployment_Provider deploymentProvider;
static TinyCLR_Api_Info deploymentApi;

struct AT91_Flash_Controller {
    uint8_t dataReadBuffer[FLASH_BLOCK_SIZE + 8];
    uint8_t dataWriteBuffer[FLASH_BLOCK_SIZE + 8];

    TinyCLR_Spi_Provider* provider;
{'fraction_non_alphanumeric': 0.04738330975954738, 'fraction_numerical': 0.04137199434229137, 'mean_word_length': 2.537836147592245, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4022275', 'n_tokens_mistral': 1879, 'n_tokens_neox': 1641, 'n_words': 431}